Themes and tokens
The CSS-variable token system, partial patches, runtime theme swaps, and the dark/light contract.
EliteChart is driven by two coordinated palettes that always stay in sync:
- CSS variables — control the surrounding UI chrome (bars, sidebars, buttons, modals).
- Chart theme tokens — control the canvas itself (candle colors, grid, crosshair, price pill).
The shipped @elitechart/elitechart/styles.css wires both palettes
together so the UI and the canvas always match. You customise by
overriding either side.
Quick example
How it works
EliteChart ships two palettes — html.dark and html.light —
toggled at runtime via the top-bar moon/sun icon and persisted to
localStorage['elitechart-ui'].
Three customisation paths, in order of permanence:
- CSS variable overrides — drop a stylesheet that overrides
--accent-blue,--up,--down,--bg-primary, etc. onhtml.darkandhtml.light. Permanent. useThemeStore.setOverride(key, value)— patch a single token at runtime. Persists to localStorage.chart.patchTheme(...)viahandle.patchTheme— session-only tweaks; reset on reload.
Brand colors — CSS overrides
Token reference
Backgrounds
| Variable | Role |
|---|---|
--bg-primary | Canvas background + shell base |
--bg-secondary | Floating panels, drawers, modals |
--bg-tertiary | Elevated cards within panels |
Series (P&L semantic)
| Variable | Role |
|---|---|
--up | Bullish candle / positive P&L |
--up-soft | Low-alpha tint for bullish fills |
--down | Bearish candle / negative P&L |
--down-soft | Low-alpha tint for bearish fills |
Accent
| Variable | Role |
|---|---|
--accent-blue | Primary accent (buttons, focus, toasts) |
--accent-blue-hover | Hover state of accent |
Text
| Variable | Role |
|---|---|
--text-primary | Primary body text |
--text-secondary | Secondary labels |
--text-tertiary | Metadata, timestamps, captions |
Sizing (vw-clamped)
| Variable | Role |
|---|---|
--topbar-h | Top bar height |
--leftbar-w | Left rail width |
--rightbar-rail-w | Right sidebar collapsed width |
--rightbar-panel-w | Right sidebar expanded width |
--bottombar-h | Bottom strip height |
--bottom-drawer-h | Bottom drawer height when open |
--fs-2xs … --fs-lg | Font size scale |
Chart canvas tokens (in-session overrides)
The Settings → Appearance tab and the theme studio
example expose four chart-canvas
tokens: bullish candle, bearish candle, background canvas, grid.
These bind to chart.patchTheme(...) under the hood and reset on
reload. For permanent branding use the CSS variable approach above.
Variations
Programmatic theme swap
Patch just a few tokens
WCAG contrast
The default tokens pass WCAG 2.1 AA on both palettes (≥ 4.5:1 for body text, ≥ 3:1 for large text). If you override, validate against the canvas using the axe-core devtools extension.