Skip to main content

Crate ratatui_style_presets

Crate ratatui_style_presets 

Source
Expand description

§ratatui-style-presets

Ready-to-use CSS themes & utilities for ratatui-style — the styling layer pre-filled, so third-party apps get a sensible look out of the box and can swap looks by changing one stylesheet.

Each preset is embedded at compile time and exposed as a &'static Stylesheet parsed with Origin::Theme, so a downstream app overrides any of it with its own Origin::User rules at equal specificity — no merge plumbing required.

§Themes & swappability

Every theme fills the same canonical semantic tokens (see SEMANTIC_TOKENS): --bg, --text, --accent, --success, … default_theme() additionally ships base component classes (Button, Panel, Text, List, …) that reference those tokens through var(). The widgets preset does the same for ratatui widget type names. So:

  • pick a palette (default / catppuccin / nord / dracula) → restyle everything,
  • layer widgets / tailwind on top → styled widgets / atomic utilities,
  • override anything with your own Origin::User rules.

§Feature flags

FeaturePreset
(none)default_theme() — always available
tailwind[tailwind()] — atomic utility classes
widgets[widgets()] — ratatui widget type defaults
catppuccin[catppuccin()] — Catppuccin palette
nord[nord()] — Nord palette
dracula[dracula()] — Dracula palette
[dependencies]
ratatui-style-presets = { version = "0.1", features = ["widgets", "catppuccin"] }

§Combine presets

merge() stacks presets into one owned stylesheet (later ones override earlier at equal specificity), and PresetBuilder does it fluently:

use ratatui_style_presets::{merge, Preset, PresetBuilder};

// Stack presets into one sheet (later ones override earlier at equal
// specificity). Add `Widgets` / `Catppuccin` / … when those features are on:
let sheet = merge(&[Preset::Default]);

// Same thing, fluently:
let sheet = PresetBuilder::new()
    .with(Preset::Default)
    .build();

Structs§

PresetBuilder
A fluent builder over merge(): stack presets, then build() into one owned stylesheet.

Enums§

Preset
A selectable preset stylesheet.

Constants§

SEMANTIC_TOKENS
The canonical, theme-agnostic semantic color-token names every shipped theme reproduces. A theme that sets exactly these tokens can be dropped in as the base stylesheet and the rest of a UI restyles for free.

Functions§

default_theme
The default theme + base component classes (Button, Panel, Text, List, Badge, …). Always available — no feature flag needed.
merge
Stack several presets into one owned stylesheet, in order.