palette-core 0.14.0

TOML-defined theme system with inheritance, CSS export, and multi-target rendering
Documentation
[![Crates.io](https://img.shields.io/crates/v/palette-core)](https://crates.io/crates/palette-core)
[![docs.rs](https://img.shields.io/docsrs/palette-core)](https://docs.rs/palette-core)
[![CI](https://github.com/jostled-org/palette-core/actions/workflows/ci.yml/badge.svg)](https://github.com/jostled-org/palette-core/actions/workflows/ci.yml)
[![Downloads](https://img.shields.io/crates/d/palette-core)](https://crates.io/crates/palette-core)
[![deps.rs](https://deps.rs/repo/github/jostled-org/palette-core/status.svg)](https://deps.rs/repo/github/jostled-org/palette-core)
[![License: MIT/Apache-2.0](https://img.shields.io/crates/l/palette-core)](LICENSE-MIT)

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, syntect, JSON, and WASM exports.

```rust
use palette_core::load_preset;

let palette = load_preset("tokyonight").unwrap();
let css = palette.to_css();
```

```css
:root {
  --bg: #1A1B26;
  --fg: #C0CAF5;
  --error: #DB4B4B;
  --syn-keyword: #BB9AF7;
  --ed-cursor: #C0CAF5;
  /* ... 136+ variables total */
}
```

## Install

```
cargo add palette-core
```

## Usage

### Terminal

```rust
use palette_core::load_preset;
use palette_core::terminal::to_terminal_theme;

let palette = load_preset("catppuccin").unwrap();
let theme = to_terminal_theme(&palette);
```

### Theme variants

Variants inherit from a base and override only what changes.

```toml
[meta]
name = "My Dark Warm"
preset_id = "my_dark_warm"
inherits = "tokyonight"

[base]
background = "#24283b"
```

### Contrast validation and auto-fix

```rust
use palette_core::{load_preset, ContrastLevel};
use palette_core::contrast::validate_palette;

let palette = load_preset("tokyonight").unwrap();
let violations = validate_palette(&palette, ContrastLevel::AaNormal);

// Auto-fix: nudge failing foregrounds to meet WCAG at resolve time
let resolved = palette.resolve_with_contrast(ContrastLevel::AaNormal);
```

## Documentation

The [guide](docs/guide.md) covers rendering targets, theme switching, custom presets, color manipulation, gradients, platform overrides, and WASM bindings.

31 presets ship built-in — Catppuccin, TokyoNight, Dracula, Nord, Gruvbox, and [more](docs/guide.md#bundled-presets). Golden Hour is an original warm-toned family (light, dusk, twilight) exclusive to palette-core. Themes can define [gradients](docs/guide.md#gradients) with OKLab/OKLCH interpolation and CSS `linear-gradient()` export. Optional [feature flags](docs/guide.md#feature-flags) enable `terminal`, `egui`, `syntect`, `snapshot`, `platform`, and `wasm` targets.

## Demos

See [p3-demo](https://github.com/jostled-org/p3-demo) for a TUI theme picker and a side-by-side [CSS](https://jostled-org.github.io/p3-demo/) preview, with a WASM demo in progress.

## License

Licensed under [Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) at your option.