niram-css1 brings standard CSS color names2 to Typst.
While Typst natively ships with eighteen predefined colors, using anything outside that set usually means hunting down a hex code. niram-css eliminates this friction by giving you access to the standard CSS color names. Instead of writing #c71585, you can just write mediumvioletred.
Key features:
-
Complete CSS Color Support: Access all 147 standard CSS color names.3
-
Flexible Naming Convention: Write color names in whatever form feels most natural to you. Inputs are automatically normalized, meaning
mediumvioletred,medium violet red,Medium Violet Red,medium-violet-red,medium_violet_red,mediumVioletRed,MediumVioletRed,MEDIUM_VIOLET_RED, andMEDIUMVIOLETREDwill all resolve to the same color.
This package requires Typst 0.13.0 or higher.
Import the package at the top of your Typst document:
#import "@preview/niram-css:0.2.0": *Then, use the css function anywhere a color value is expected:
This is #text(fill: css("mediumvioletred"))[mediumvioletred] text.That is all it takes to start using CSS color names in your document.
For more examples, please refer to the official manual.
If you wish to contribute to this package, follow the steps below to prepare your development environment. The package source is in src/lib.typ.
-
Typst: Install Typst (version 0.13.0 or higher) following the Typst installation guide. Typst is the core tool required for this project.
-
Just: Install Just, a command runner for executing predefined tasks. Refer to the available packages for installation instructions specific to your operating system.
-
tytanic: Install tytanic, a library essential for testing and working with Typst projects. Use the quickstart installation guide to get it up and running.
-
Clone the Repository: Download the project's source code by cloning the repository to your local machine:
git clone https://github.com/nandac/niram-css.git
Your development environment is now ready.
To validate the package functionality, execute the following command:
just testTo add a new test case execute:
tt new <test-case-name>This will create a new folder with the following structure under the tests directory:
├── <test-case-name>
│ ├── .gitignore
│ ├── ref
│ │ └── 1.png
│ └── test.typYou may then write your tests in the test.typ file.
For more information on writing tests using tytanic please see this guide.
Once you have written your test run:
just update
just testEnsure all tests pass before submitting changes to maintain code quality.
To test the package with an actual Typst file, install the niram-css package locally in the preview location by running:
just install-previewOnce installed, import it into your Typst file using:
#import "@preview/niram-css:0.2.0": *This allows experimentation with the package before finalizing updates.
Follow these steps to release a new version of the package:
-
Update Version Number:
- Increment the major and/or minor version number in all files referencing the old version.
-
Update CHANGELOG:
- Document added features, modifications, and optionally include a migration guide for the new version in
CHANGELOG.md. - Use the guidelines given at Keep a Changelog.
- Document added features, modifications, and optionally include a migration guide for the new version in
-
Commit Changes:
-
Push your updates to the repository:
git add -u git commit -m "Bump version and update CHANGELOG" git push
-
-
Tag the Release:
-
Create and push a new tag for the version:
git tag -a v<version> -m "<release-text>" git push --tags origin
-
-
Create a Pull Request:
- The release action in GitHub will create a branch in your fork of typst-packages.
- Use this branch to open a pull request in the main Typst Packages repository.
Special thanks to the Typst community on Discord for their invaluable assistance and support during the development of this package.
Footnotes
-
In Tamil, niram (நிறம், /n̪ɪrɐm/) means "color"—a fitting name for a coloring package. ↩
-
While the official W3C specification refers to these as "color keywords," they are almost universally known among web developers as "color names." This documentation uses the common vernacular for readability. ↩