title: How-To: Custom Theme description: Apply a custom visual theme to rs-grid using CSS variables or a Theme struct.
rs-grid supports two theming approaches: CSS custom properties (recommended
for runtime switching) and a Rust Theme struct (for static or programmatic
control).
Approach 1 — CSS variables (recommended)
Define --rs-grid-* variables on :root (or any ancestor of the canvas).
Call theme_from_css_vars() to read them into a Theme struct, then pass
it to the grid.
1. Define your palette in CSS
See CSS Variables reference for the full list.
2. Build a Theme from CSS vars in Rust
3. Pass it to the grid component
4. Switch themes at runtime
Toggle a CSS class and re-read the variables:
Approach 2 — Rust Theme struct
Build a Theme directly without CSS variables. Useful for server-side
theming, tests, or embedding in a non-browser context.
Built-in themes
See Built-in Themes for the color values.
Apply per-cell CSS classes
For cell-level styling beyond the global theme, use CellFormat::Styled:
Then wire up a class resolver on the canvas to map class strings to colors:

