styles/plotly/themeTokens#
currentThemeBase()#
Whether the active theme is a dark one.
Reads data-theme-base, which every theme (built-in or plugin-provided)
stamps alongside data-theme — an id allowlist would silently mislabel
warm-paper and every plugin skin as dark.
Returns#
"light" | "dark"
currentThemeName()#
Current value of data-theme on , or 'dark' before it is set.
Returns#
string
fadeAgainstPlotBg()#
De-emphasise a plot color WITHOUT handing Plotly a raw alpha.
Fading a marker by dropping its opacity is how a demoted peak stops competing with a reported one — but opacity is also how a graphical object stops being perceivable: mid-blue at 45% over a white plot background sits at ~2.1:1, under the 3:1 minimum for non-text content. So the fade is computed as an explicit blend toward the plot background (same visual result, an opaque color Plotly can measure) and then walked back toward the full-strength color until it clears the contrast floor.
The returned color therefore carries NO information on its own — the tier is read from the glyph's shape and stroke weight. This only stops the weakest tiers from disappearing into the paper.
Parameters#
| Parameter | Type |
|---|---|
color |
string |
opacity |
number |
background? |
string |
minContrast? |
number |
Returns#
string
getPlotColors()#
Resolved plot colors for the current theme. Cached; recomputed only when
data-theme changes.
Returns#
invalidatePlotColors()#
Drop all caches. Call if tokens are mutated without a data-theme flip.
Returns#
void
resolveToken()#
Resolve a single CSS custom property to a literal color string.
name may be given with or without the leading --.
Parameters#
| Parameter | Type |
|---|---|
name |
string |
fallback? |
string |
Returns#
string
resolveTokens()#
Resolve several tokens at once (single getComputedStyle pass).
Type Parameters#
| Type Parameter |
|---|
K extends string |
Parameters#
| Parameter | Type |
|---|---|
names |
Record<K, string> |
Returns#
Record<K, string>
seriesColor()#
Pick the Nth categorical color, wrapping with modulo.
Parameters#
| Parameter | Type |
|---|---|
index |
number |
Returns#
string
seriesColorAlpha()#
Same as seriesColor but tinted to alpha.
Parameters#
| Parameter | Type |
|---|---|
index |
number |
alpha |
number |
Returns#
string
themedPlotlyLayout()#
Plotly layout fragment carrying the current theme's chrome. Merge this
after the selected template so it wins over the template's baked colors.
Returns#
Layout
usePlotColors()#
Resolved plot colors, re-rendering the component when the theme changes.
Prefer this over getPlotColors() inside React components.
Returns#
withAlpha()#
Add alpha to a resolved token color. Accepts #rgb, #rrggbb,
rgb()/rgba(). Returns the input unchanged if it cannot be parsed.
Parameters#
| Parameter | Type |
|---|---|
color |
string |
alpha |
number |
Returns#
string
MIN_GRAPHIC_CONTRAST#
Non-text contrast minimum (WCAG 2.1 SC 1.4.11) for a graphical object.
PlotThemeColors#
Properties#
accent#
axisFontColor#
axisLineColor#
border#
critical#
error#
gridColor#
hoverBg#
hoverBorder#
hoverFont#
idle#
info#
integrationCurve#
isDark#
True when the resolved theme is a dark one.
jLabel#
legendBg#
legendBorder#
ok#
onAccent#
onSolid#
overlayBorder#
overlayHover#
overlayScrim#
overlaySelected#
paperBg#
patternLabel#
peakLabel#
peakLabelManual#
peakLabelSelected#
plotBg#
projection#
series#
surfaceCard#
surfaceFloating#
text#
textDisabled#
textSecondary#
theme#
The theme these values were resolved for.