https://github.com/mintlu8/parse-color
A crate that provides conversion from CSS color names or TailwindCSS classes to RGBA colors, in the form of [u8; 4].
https://github.com/mintlu8/parse-color
Last synced: 20 days ago
JSON representation
A crate that provides conversion from CSS color names or TailwindCSS classes to RGBA colors, in the form of [u8; 4].
- Host: GitHub
- URL: https://github.com/mintlu8/parse-color
- Owner: mintlu8
- License: mit
- Created: 2023-10-14T15:21:46.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-15T10:06:31.000Z (over 2 years ago)
- Last Synced: 2025-09-19T21:18:35.008Z (9 months ago)
- Language: Rust
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parse-color
A crate that provides conversion from CSS color names or TailwindCSS classes to RGBA colors, in the form of [u8; 4].
## Examples
```rust
assert_eq!(parse_color::parse("Red"), Some([255, 0, 0, 255]));
assert_eq!(parse_color::parse("Transparent"), Some([0, 0, 0, 0]));
assert_eq!(parse_color::parse("light coral"), Some([240, 128, 128, 255]));
assert_eq!(parse_color::parse("Rebecca-Purple"), Some([102, 51, 153, 255]));
// note the 0 value is only allowed on black/white/transparent
assert_eq!(parse_color::parse_tailwind("white", 0), Some([255, 255, 255, 255]));
assert_eq!(parse_color::parse_tailwind("sky", 400), Some([56, 189, 248, 255]));
assert_eq!(parse_color::parse_tailwind("fuchsia", 900), Some([112, 26, 117, 255]));
```