24 releases (5 breaking)
Uses new Rust 2024
| new 0.6.10 | Mar 7, 2026 |
|---|---|
| 0.6.9 | Mar 6, 2026 |
| 0.6.2 | Feb 28, 2026 |
| 0.5.1 | Feb 25, 2026 |
| 0.1.0 | Feb 22, 2026 |
#32 in Rendering
77KB
1.5K
SLoC
Need a color palette? Do you have to hand-roll it?
Palette Core is a theme engine that turns TOML palette definitions into CSS, terminal, egui, JSON, and WASM exports.
use palette_core::preset;
let palette = preset("tokyonight").expect("builtin preset");
let css = palette.to_css();
:root {
--bg: #1A1B26;
--fg: #C0CAF5;
--error: #DB4B4B;
--syn-keyword: #BB9AF7;
--ed-cursor: #C0CAF5;
/* ... 95 variables total */
}
Install
cargo add palette-core
Usage
Terminal
use palette_core::preset;
use palette_core::terminal::to_terminal_theme;
let palette = preset("catppuccin").expect("builtin preset");
let theme = to_terminal_theme(&palette);
Theme variants
Variants inherit from a base and override only what changes.
[meta]
name = "My Dark Warm"
preset_id = "my_dark_warm"
inherits = "tokyonight"
[base]
background = "#24283b"
Contrast validation
use palette_core::{preset, ContrastLevel};
use palette_core::contrast::validate_palette;
let palette = preset("tokyonight").expect("builtin preset");
let violations = validate_palette(&palette, ContrastLevel::AaNormal);
Documentation
The guide covers rendering targets, theme switching, custom presets, color manipulation, platform overrides, and WASM bindings.
31 presets ship built-in — Catppuccin, TokyoNight, Dracula, Nord, Gruvbox, and more. Golden Hour is an original warm-toned family (light, dusk, twilight) exclusive to palette-core. Optional feature flags enable terminal, egui, snapshot, platform, and wasm targets.
License
Licensed under Apache-2.0 or MIT. Contributions welcome via pull request.
Dependencies
~0.6–3.5MB
~66K SLoC