Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
chromata
1000+ editor color themes as compile-time Rust constants.
[!IMPORTANT] Pre-1.0 — the API may change between minor versions. Pin your dependency version.
Highlights
- 1000+ themes — base16, base24, vim, emacs, and hand-curated ecosystems
- Zero runtime cost — every theme is a
conststruct, no parsing, no allocation - 25+ semantic color roles — bg, fg, keyword, string, function, error, and more
- Feature-gated — compile only the theme families you need (~20KB for
popular) - 18 framework integrations — ratatui, egui, plotters, image, bevy, wgpu, and more via optional features
no_stdcompatible — works in embedded and WASM targets- WCAG contrast utilities — luminance and contrast ratio calculations built in
Contents
- For Everyone — What chromata does, install, quick start
- For Developers — Architecture, traits, code generation pipeline
- Feature Flags | Development | License
For Everyone
Every Rust TUI, GUI, and terminal application needs colors. Most projects either hardcode hex values, copy-paste palettes from README files, or pull in a full theme engine with runtime parsing and file I/O. If you just want "give me the Gruvbox Dark background color," that's overkill.
chromata provides every popular editor and terminal color theme as compile-time const data. No file parsing. No runtime allocation. No dependencies by default. Add chromata to your Cargo.toml, reference a theme by name, and get colors at zero cost.
Each theme is a struct with named fields for semantic color roles — background, foreground, keyword, string, comment, error, plus a full accent palette. Themes are organized by family (base16, base24, vim, emacs) and feature-gated so you only compile what you use.
Install
[]
= "0.3.0"
Or with framework integration:
[]
= { = "0.3.0", = ["ratatui-integration"] }
Quick start
use gruvbox;
Generic theme parameter
// Caller picks the theme:
render_ui;
render_ui;
Theme discovery
use Variant;
let dark_themes: = collect_all_themes
.into_iter
.filter
.collect;
println!;
Use cases
- TUI applications — ratatui, cursive, crossterm-based apps
- GUI applications — egui, iced, slint, bevy, macroquad
- Graphics and rendering — plotters charts, image processing, wgpu, tiny-skia
- Terminal coloring — colored, owo-colors, termion
- Syntax highlighting — syntect, tree-sitter, or similar
- Color science — palette crate for color space conversions
- Theme preview tools — compare themes side-by-side
- CSS generation — export custom properties for web frontends
For Developers
Architecture
%%{init: {'theme': 'neutral'}}%%
graph TD
DATA["data/<br>YAML theme files"] -->|cargo xtask generate| GEN["xtask<br>code generator"]
GEN --> SRC["src/base16/*.rs<br>src/base24/*.rs<br>..."]
SRC --> LIB["lib.rs<br>feature-gated modules"]
LIB --> TYPES["types.rs<br>Color, Theme, Variant"]
LIB --> INT["integration/<br>18 framework integrations"]
Module tree
src/
├── lib.rs # Re-exports, feature gates, #![no_std]
├── types.rs # Color, Theme, Variant, Contrast, Base16Palette, Base24Palette
├── iter.rs # collect_all_themes()
├── popular/ # Feature: "popular" (default) — curated 49 best themes
│ ├── mod.rs
│ ├── gruvbox.rs, solarized.rs, nord.rs, dracula.rs, ...
│ └── (24 family files, 49 themes total)
├── base16/ # Feature: "base16" — ~305 tinted-theming schemes
│ └── mod.rs
├── base24/ # Feature: "base24" — ~184 extended base16 schemes
│ └── mod.rs
├── vim/ # Feature: "vim" — ~464 vim colorschemes
│ └── mod.rs
├── emacs/ # Feature: "emacs" — ~102 emacs themes
│ └── mod.rs
└── integration/ # Optional framework conversions (18 crates)
├── mod.rs
├── ratatui.rs, egui.rs, crossterm.rs, iced.rs
├── plotters.rs, image.rs, palette.rs, syntect.rs
├── bevy_color.rs, macroquad.rs, wgpu.rs, tiny_skia.rs, slint.rs
└── colored.rs, owo_colors.rs, termion.rs, cursive.rs, comfy_table.rs
The Theme struct
Every theme is a const Theme with metadata, UI colors, syntax colors, diagnostics, and a named accent palette:
Framework conversions
Framework integrations use From<Color> conversions gated behind optional features:
// With the ratatui-integration feature:
use gruvbox;
let style = default
.fg
.bg;
Each integration implements From<Color> for the framework's color type, so you can use .into() directly.
Code generation pipeline
Themes are generated from upstream data files using cargo xtask generate (Strategy B — one-time generation, checked into git):
data/base16/*.yaml ──┐
data/base24/*.yaml ──┤──▶ cargo xtask generate ──▶ src/{family}/*.rs
data/vim/*.vim ──────┤
data/emacs/*.el ─────┘
The xtask reads structured data (YAML for base16/base24, normalized JSON for vim/emacs) and emits .rs files containing const Theme definitions. This avoids build-time parsing for downstream consumers.
Feature Flags
| Feature | Themes | Description | Default |
|---|---|---|---|
popular |
49 | Curated best themes (gruvbox, catppuccin, nord, ...) | Yes |
base16 |
305 | Base16 themes from tinted-theming/schemes | No |
base24 |
184 | Base24 themes (extended base16 with 8 extra slots) | No |
vim |
464 | Vim colorschemes from vim-colorschemes repos | No |
emacs |
102 | Emacs themes from emacs-themes-site | No |
all |
1104 | Enable all theme families | No |
bevy-color-integration |
— | From<Color> for bevy_color types |
No |
colored-integration |
— | From<Color> for colored types |
No |
comfy-table-integration |
— | From<Color> for comfy-table types |
No |
crossterm-integration |
— | From<Color> for crossterm types |
No |
cursive-integration |
— | From<Color> for cursive types |
No |
egui-integration |
— | From<Color> for egui types |
No |
iced-integration |
— | From<Color> for iced types |
No |
image-integration |
— | From<Color> for image types |
No |
macroquad-integration |
— | From<Color> for macroquad types |
No |
owo-colors-integration |
— | From<Color> for owo-colors types |
No |
palette-integration |
— | From<Color> for palette types |
No |
plotters-integration |
— | From<Color> for plotters types |
No |
ratatui-integration |
— | From<Color> for ratatui types |
No |
slint-integration |
— | From<Color> for slint types |
No |
syntect-integration |
— | From<Color> for syntect types |
No |
termion-integration |
— | From<Color> for termion types |
No |
tiny-skia-integration |
— | From<Color> for tiny-skia types |
No |
wgpu-integration |
— | From<Color> for wgpu types |
No |
serde-support |
— | Serialize/deserialize themes and colors | No |
Development
# Run examples
# Integration examples (require feature flags)
Minimum supported Rust version
Rust edition 2024, targeting stable Rust 1.85+.
Support
If chromata is useful to your projects, consider supporting development via thanks.dev.
License
This project is licensed under the GNU General Public License v3.0. See LICENSE for details.