Theming Overview

Pipeline

CSS variables (:root) → theme_from_css_vars() → Theme struct → SceneBuilder → canvas
  1. You define --rs-grid-* CSS custom properties on :root
  2. At mount time, theme_from_css_vars() reads them from the computed style
  3. Missing variables fall back to Theme::light() defaults
  4. The Theme is passed to SceneBuilder which uses it for all rendering

Theme struct

The Theme struct holds all visual properties:

  • Colors — background, text, borders, selection, scrollbar, hover, search
  • Typography — font sizes, header bold
  • Spacing — cell padding, scrollbar width and radius

See CSS Variables Reference for the complete list.

Two ways to set the theme

Add variables to your stylesheet:

:root {
  --rs-grid-bg: #1a1b26;
  --rs-grid-cell-text: #c0caf5;
}

2. Programmatic Theme struct

Create a Theme directly in Rust:

let theme = Theme {
    bg: Color::rgb(26, 27, 38),
    cell_text: Color::rgb(192, 202, 245),
    ..Theme::dark()
};

To apply the theme dynamically:

Leptos
Vanilla JS
Dioxus
Yew

Pass the theme as a signal for reactive updates:

let (theme, set_theme) = create_signal(Theme::dark());
// Update theme dynamically
set_theme.set(Theme::light());

When are variables read?

CSS variables are read once at mount time. They are not re-read on every frame. To change the theme dynamically:

Leptos
Vanilla JS
Dioxus
Yew

Use a theme signal — the component will re-render automatically when the signal updates.

Default themes

rs-grid ships with two programmatic defaults:

MethodPalette
Theme::light()AG Grid-inspired light palette
Theme::dark()Tokyo Night-inspired dark palette

See Built-in Themes for details and additional themes.