Build a ChartTheme by overlaying CSS-custom-property values onto a
base theme — the adapter that lets a chart track a design system's tokens
(and its dark/light toggle) without hand-mirroring hex values.
resolve receives a VarReader and returns only the slots to override
(a ChartThemeOverrides); the result is base deep-merged with them.
The typed ChartTheme stays the one styling channel — this generates it
from CSS, it doesn't add a second one.
DOM-only, by design. It reads getComputedStyle off opts.element (or
document.documentElement). With no DOM — SSR, an OffscreenCanvas worker —
every readVar returns its fallback (or undefined, kept from base), so
the call is safe and returns the base theme (plus any literal fallbacks). For
a live chart that follows a theme toggle, use useChartTheme, which
wraps this and re-resolves on a data-theme change — don't call cssVarTheme
per frame (getComputedStyle is a layout read).
Build a ChartTheme by overlaying CSS-custom-property values onto a
basetheme — the adapter that lets a chart track a design system's tokens (and its dark/light toggle) without hand-mirroring hex values.resolvereceives a VarReader and returns only the slots to override (a ChartThemeOverrides); the result isbasedeep-merged with them. The typedChartThemestays the one styling channel — this generates it from CSS, it doesn't add a second one.DOM-only, by design. It reads
getComputedStyleoffopts.element(ordocument.documentElement). With no DOM — SSR, an OffscreenCanvas worker — everyreadVarreturns its fallback (orundefined, kept frombase), so the call is safe and returns the base theme (plus any literal fallbacks). For a live chart that follows a theme toggle, use useChartTheme, which wraps this and re-resolves on adata-themechange — don't callcssVarThemeper frame (getComputedStyleis a layout read).