#color #color-palette #radix #constants #ui #expressed

radix-colors-rs

The Radix UI Colors palettes expressed in Rust constants

2 releases

0.1.1 Dec 26, 2024
0.1.0 Dec 26, 2024

#14 in #radix

MIT license

53KB

radix-colors-rs

I got tired of manually copying Radix colors into my projects, so I made this crate. It contains a mini JS project and some Nix code to produce a colors.json file. This file is parsed by rust macros to generate the color constants.

If you're coming from some other language, you're welcome also to just use the colors.json file as is.


lib.rs:

radix-colors-rs is a library that provides color constants from the Radix UI Colors library.

All constant names are generated from the palette and color names in the JSON file. Having all the constants loose like this is great for cherry-picking, but if you need to use all the colors, consider directly using the JSON file we're generating these from.

Every color constant name is the palette name taken from the JS library (blueDarkP3, pinkA) combined with the color name (orangeA7, mint2) like {palette}_{color}, and uppercased.

Regular colors, alpha colors, and P3 colors are given separate types.

Dependencies

~1.8–2.5MB
~56K SLoC