1 unstable release
Uses new Rust 2024
| 0.1.0 | Mar 21, 2026 |
|---|
#201 in Value formatting
18KB
289 lines
tw-colors
The complete Tailwind CSS v4 color palette as (u8, u8, u8) RGB constants for Rust.
Zero dependencies. Just constants.
Installation
cargo add tw-colors
Usage
Every color is a pub const of type RGB, which is a type alias for (u8, u8, u8):
use tw_colors::{RGB, BLUE_500, RED_400, SLATE_900};
// Use directly as an RGB tuple
let color: RGB = BLUE_500; // (43, 127, 255)
// Destructure into components
let (r, g, b) = RED_400; // (255, 100, 103)
// Pass anywhere that accepts (u8, u8, u8)
fn set_background(color: (u8, u8, u8)) { /* ... */ }
set_background(SLATE_900);
With Freya
The RGB tuples work directly with Freya:
use freya::prelude::*;
use tw_colors::BLUE_500;
fn app() -> impl IntoElement {
rect()
.background(BLUE_500)
.child("Hello, Tailwind!")
}
Available Colors
All constants follow the naming pattern COLOR_SHADE, where shade is one of:
50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950.
Chromatic
| Family | Example |
|---|---|
RED |
RED_500 = (251, 44, 54) |
ORANGE |
ORANGE_500 = (255, 105, 0) |
AMBER |
AMBER_500 = (254, 154, 0) |
YELLOW |
YELLOW_500 = (240, 177, 0) |
LIME |
LIME_500 = (124, 207, 0) |
GREEN |
GREEN_500 = (0, 201, 80) |
EMERALD |
EMERALD_500 = (0, 188, 125) |
TEAL |
TEAL_500 = (0, 187, 167) |
CYAN |
CYAN_500 = (0, 184, 219) |
SKY |
SKY_500 = (0, 166, 244) |
BLUE |
BLUE_500 = (43, 127, 255) |
INDIGO |
INDIGO_500 = (97, 95, 255) |
VIOLET |
VIOLET_500 = (142, 81, 255) |
PURPLE |
PURPLE_500 = (173, 70, 255) |
FUCHSIA |
FUCHSIA_500 = (225, 42, 251) |
PINK |
PINK_500 = (246, 51, 154) |
ROSE |
ROSE_500 = (255, 32, 86) |
Neutrals
| Family | Example |
|---|---|
SLATE |
SLATE_500 = (98, 116, 142) |
GRAY |
GRAY_500 = (106, 114, 130) |
ZINC |
ZINC_500 = (113, 113, 123) |
NEUTRAL |
NEUTRAL_500 = (115, 115, 115) |
STONE |
STONE_500 = (121, 113, 107) |
TAUPE |
TAUPE_500 = (124, 109, 103) |
MAUVE |
MAUVE_500 = (121, 105, 123) |
MIST |
MIST_500 = (103, 120, 124) |
OLIVE |
OLIVE_500 = (124, 124, 103) |
29 color families x 11 shades = 319 constants covering the full Tailwind CSS v4 palette.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.