Expand description
§Material Color Utilities
Material Design 3 color utilities for Rust, including HCT (Hue/Chroma/Tone), tonal palettes, and dynamic color schemes.
§Quick start
Generate a theme from a seed color and query tokens by name:
use material_color_rs::generate_theme_from_color;
let theme = generate_theme_from_color("#39C5BB")?;
let light = &theme.schemes["light"];
let primary = light.get_argb("primary").unwrap();
assert_ne!(primary, 0);§Data model
MaterialThemestores colors asu32ARGB (0xAARRGGBB) for fast access.MaterialThemeJsonis a hex-string representation intended for import/export.
§Feature flags
iced: enablesSchemeColors::get_icedfor converting tokens toiced::Color.
Re-exports§
pub use hct::Hct;pub use palettes::TonalPalette;pub use scheme::DynamicScheme;pub use scheme::Variant;
Modules§
- contrast
- Contrast utilities used by dynamic colors.
- dynamiccolor
- Material dynamic color tokens and helpers.
- hct
- HCT and CAM16 color science primitives.
- palettes
- Tonal palettes.
- scheme
- Dynamic theme schemes.
- utils
- Internal math and color helpers.
Structs§
- Material
Theme - A generated Material theme.
- Material
Theme Json - Material theme JSON structure, compatible with common Material Theme exports.
- Scheme
Colors - A token map for a single scheme (e.g.
"light"or"dark").
Functions§
- argb_
to_ hex - Converts an ARGB integer to an uppercase hex RGB string (
"#RRGGBB"). - argb_
to_ rgb - Converts an ARGB integer to an
(r, g, b)tuple. - argb_
to_ rgba - Converts an ARGB integer to an
[r, g, b, a]array. - argb_
to_ rgba_ f32 - Converts an ARGB integer to an
[r, g, b, a]float array (each channel in0.0..=1.0). - generate_
theme_ from_ color - Generates a Material theme from a seed color.
- hex_
to_ argb - Parses a hex RGB string (
"#RRGGBB"or"RRGGBB") into an opaque ARGB color (0xFFRRGGBB).