Expand description
TOML-defined theme system with inheritance and multi-target export.
palette-core parses theme files written in TOML, resolves single-level
inheritance between variants, and produces a Palette — a typed color
map covering base, semantic, syntax, editor, diff, surface, typography,
and terminal-ANSI slots.
§Quick start
use palette_core::{load_preset, Registry};
// Load a built-in theme (returns PaletteError on unknown ID)
let palette = load_preset("catppuccin").unwrap();
// Same API, different preset
let palette = load_preset("tokyonight").unwrap();
// Registry: built-ins + custom themes from disk
let mut reg = Registry::new();
if let Err(e) = reg.add_dir("./my-themes".as_ref()) {
eprintln!("failed to load custom themes: {e}");
}
for info in reg.list() {
println!("{}: {}", info.id, info.name);
}§Export targets
| Target | Feature | Function |
|---|---|---|
| CSS custom properties | — | Palette::to_css |
| JSON snapshot | snapshot | Palette::to_json |
ratatui Color | terminal | terminal::to_terminal_theme |
egui Visuals | egui | egui::to_egui_visuals |
syntect Theme | syntect | syntect::to_syntect_theme |
| WASM/JS bindings | wasm | wasm module |
Re-exports§
pub use color::Color;pub use contrast::ContrastLevel;pub use error::PaletteError;pub use gradient::ColorSpace;pub use gradient::Gradient;pub use gradient::GradientColor;pub use gradient::GradientDef;pub use gradient::GradientStop;pub use palette::GradientDefs;pub use palette::Palette;pub use palette::PaletteMeta;pub use registry::Registry;pub use registry::ThemeInfo;pub use registry::load_preset;pub use registry::load_preset_file;pub use registry::preset_ids;pub use resolved::ResolvedPalette;pub use style::StyleModifiers;
Modules§
- color
- 8-bit RGB color type and hex parsing.
- contrast
- WCAG 2.1 contrast ratio checking and palette validation.
- css
- CSS custom-property export.
- egui
- egui integration: apply a
Paletteto egui’sVisuals. - error
- Error types for theme loading and parsing.
- gradient
- Multi-stop color gradient with perceptual interpolation. Multi-stop color gradients with perceptual interpolation.
- manifest
- Raw TOML manifest types before color resolution.
- manipulation
- HSL color manipulation: lighten, darken, saturate, blend.
- merge
- Single-level manifest inheritance (variant over base).
- palette
- Resolved color palette and color-group structs.
- platform
- Platform-specific color overrides (e.g. macOS, Windows, Linux).
- registry
- Built-in preset registry and theme discovery.
- resolved
- Resolved palette types with concrete Color fields.
Resolved palette types with concrete
Colorfields. - snapshot
- JSON serialization for palettes.
- style
- Text style modifiers for syntax tokens. Text style modifiers for syntax tokens.
- syntect
- syntect
Themegeneration from resolved palettes. Convert a resolved palette into a syntectTheme. - terminal
- Ratatui integration: convert a
Paletteinto terminal-native colors.