Theming (Light & Dark)
ApexStock has two layers of styling: the chart series (candles, indicator lines) styled with standard ApexCharts options, and the UI chrome (toolbar, dropdowns, drawing controls, zoom pill, popups) styled with a single namespace of CSS custom properties. This page covers both.
Light and dark mode
Set the mode when you create the chart:
const apexStock = new ApexStock(document.querySelector('#chart'), {
chart: { height: 500 },
series: [{ name: 'ACME', data: candles }],
theme: { mode: 'dark' }, // 'light' (default) or 'dark'
})
apexStock.render()
Switching at runtime
Use updateTheme() to flip modes without rebuilding the chart. Indicators, trading overlays, and zoom state are preserved, and the UI chrome recolors along with the series:
apexStock.updateTheme('dark') // or 'light'
const current = apexStock.getTheme() // -> 'light' | 'dark'
A common pattern is to mirror your app's theme toggle:
themeToggle.addEventListener('change', (e) => {
apexStock.updateTheme(e.target.checked ? 'dark' : 'light')
})
From 0.6.0 the main chart switches as well. After updateTheme(), setThemePreset() or update({ theme: { mode } }), its OHLC tooltip, text color and plot background follow the new theme instead of keeping the one the chart was built with, on every supported ApexCharts version. A plain light or dark mode leaves the main plot transparent so the ApexStock surface shows through, as on the indicator panes; a preset keeps its own plot background. After a switch to dark, main-pane series without colors of their own take ApexCharts' dark palette, as a chart built dark does. A tooltip.theme, chart.foreColor or theme.palette you set yourself is kept.
From ApexStock 0.6.0, an app that loads an Ignite UI theme can let it set the toolbar, legend, rise and fall colors and dark mode, through an add-on that your existing licence covers. See Using with Ignite UI.
Theme presets
A preset is a named layer on top of light or dark that retints both surfaces at once: the chart (candles, grid, axis labels, plot background) and the chrome (toolbar, dropdowns, legend).
apexStock.setThemePreset('arctic')
apexStock.getThemePreset() // -> 'arctic', or null for a plain mode
Or at construction:
const apexStock = new ApexStock(el, {
theme: { preset: 'graphite' },
// ...
})
Six ship, light-first: paper, arctic, mint, linen, rose, graphite.
Each carries its own base mode, so selecting one sets the mode too. The price lines follow the preset's accent; the indicator palette stays the base mode's, so a preset never makes two indicators indistinguishable. A preset survives a theme or chart-type switch and a data update, and is captured by getState() as theme.preset.
From 0.6.0 the preset's rise and fall colors, or candle colors passed to update(), reach every place that shows them: the legend, the analysis panel, the candles after a chart-type switch (back to candlestick included) and the measure box. A measure drawn with its own upColor or downColor keeps them. In a plain light or dark mode these keep their own colors, so a chart without a preset looks as it did.
updateTheme(mode) clears a preset, since asking for a plain mode is asking for the plain mode.
Registering your own
ApexStock.registerTheme('desk', {
mode: 'dark',
up: '#22c55e',
down: '#f43f5e',
grid: '#1f2937',
axis: '#94a3b8',
background: '#0b1220',
accent: '#38bdf8',
})
ApexStock.getThemePresets() // -> every registered name
Any subset of those keys works; the rest are backfilled from the base mode. A preset the restoring app does not know falls back to its base mode rather than failing, so a saved state is always loadable.
From 0.6.0, presets live in the theme registry every Apex product on the page shares. A theme registered from another product, for example ApexCharts.registerTheme('acme', { tokens: { accent, surface, fore, grid } }), is usable as theme.preset and is listed by getThemePresets(): its accent, surface, fore and grid tokens fill the preset's accent, plot background, axis text and grid, and its mode (light when unset) picks the base. A preset you register with ApexStock.registerTheme() is stated the same way, so the other products can name it. Nothing changes for a page that registers presets only with ApexStock.
Restyling the UI chrome
The toolbar and all controls are styled with CSS custom properties under a single --apexstock-* namespace, declared on every ApexStock element ([class^="apexstock-"]). They never leak out to your page, and each mode has its own palette. Override the light-* tokens to restyle light mode, the dark-* tokens for dark. A few of them read in from the shared --apx-* tokens; see Family tokens.
From 0.6.0 the toolbar's light and dark colors and the font are rules in the stylesheet rather than a <style> each chart wrote into the page <head>. Each chart keeps its own mode's dropdown colors next to a chart in the other mode, a chart inside a shadow root gets the toolbar colors and font too, and chart.fontFamily applies to its own chart only. A single chart in the light DOM looks the same as before.
This is separate from the chart series. Candle and indicator-line colors are ApexCharts options (
plotOptions.candlestick.colors,theme.mode, per-seriescolors), not--apexstock-*tokens.
Override recipe
Because ApexStock injects its stylesheet at runtime, matching its specificity and "loading after" is not reliable. Go one notch higher in specificity instead: the light/dark theme class is already on each chart container, so target it.
/* Restyle every ApexStock chart on the page */
.apexstock-theme-light [class^="apexstock-"] {
--apexstock-light-bg: #0b0e11;
--apexstock-light-text: #e6edf3;
--apexstock-blue: #f5a623; /* accent, shared by both modes */
}
.apexstock-theme-dark [class^="apexstock-"] {
--apexstock-dark-bg: #000000;
--apexstock-dark-text: #e6edf3;
}
Both selectors have specificity 0,2,0, so they win regardless of load order.
Restyle one chart only
Add your own class to the element you pass to new ApexStock(el, …) (or any ancestor) and scope to it:
<div class="my-chart">
<div id="chart"></div>
</div>
.my-chart [class^="apexstock-"] {
--apexstock-blue: #16a34a;
--apexstock-border-radius-md: 14px;
}
The drawing settings popup
From 0.6.0 the popup that opens on a selected drawing is mounted inside the chart container, so it follows that chart's mode, including after a theme switch, and no longer turns dark because of body.dark-mode or another dark chart on the page. To restyle it for dark mode, target it under the chart's dark class:
.apexstock-chart.apexstock-theme-dark .apexstock-element-popup {
--apexstock-dark-bg: #111827;
}
Family tokens (--apx-*)
Every product in the ApexCharts family reads the same root tokens, so a page can state its brand once and have stock charts, plots, maps, trees, flow diagrams and Gantt charts all follow:
| Token | Role |
|---|---|
--apx-accent | The color that means interactive or selected |
--apx-fore | Text and anything that must stay legible on the surface |
--apx-grid | Hairlines: borders, gridlines, dividers |
--apx-surface | The plane content sits on |
--apx-series-1 ... --apx-series-N | An ordered categorical palette (1-based), read by the charts through ApexCharts |
--apx-font-family | The font of the toolbar, menus and charts, below chart.fontFamily (from 0.6.0) |
:root {
--apx-accent: #0f766e;
--apx-fore: #1f2937;
--apx-grid: #e4e7ec;
--apx-surface: #ffffff;
}
Custom properties inherit, so declaring them on :root reaches every chart on the page. They sit below anything you set yourself, so adopting them cannot change a chart you had already themed:
--apexstock-* you set > --apx-* family token > built-in default
In the chrome, --apexstock-light-bg, --apexstock-light-border, --apexstock-light-text, --apexstock-light-divider and --apexstock-blue take them. Everything else keeps its built-in default.
Dark mode does not. One set of --apx-* values describes one appearance, and ApexStock's mode comes from theme.mode, not from the page, so a light brand surface with theme.mode: 'dark' would paint the dark palette white. The dark palette stays self-contained instead; brand it by overriding the --apexstock-dark-* tokens with the override recipe. The one design system ApexStock follows in dark mode is Ignite UI, and only from a dark Ignite UI theme, with the add-on loaded. While it does, the --apx-* tokens you set rank above its colors in dark mode too.
theme: { tokens: false } stops the charts reading the --apx-* tokens for one stock chart. Copying the theme template below wholesale is the stylesheet-side opt-out: its explicit values beat the family tokens, so delete the lines you want left to them.
Token reference
Light palette (apexstock-theme-light)
| Token | Default | Controls |
|---|---|---|
--apexstock-light-bg | #ffffff | Surface background (toolbar controls, dropdowns) |
--apexstock-light-surface-2 | #f8fafc | Secondary surface |
--apexstock-light-border | #e4e7ec | Default borders |
--apexstock-light-border-strong | #d0d5dd | Hover/emphasis borders |
--apexstock-light-hover | #f2f4f7 | Hover background |
--apexstock-light-text | #1f2937 | Primary text / icon stroke |
--apexstock-light-muted | #667085 | Secondary text |
--apexstock-light-selected | #eef4ff | Selected option background |
--apexstock-light-divider | #e4e7ec | Toolbar dividers |
--apexstock-light-shadow | 0 6px 24px rgba(16,24,40,.14) | Dropdown/popup shadow |
Dark palette (apexstock-theme-dark)
| Token | Default | Controls |
|---|---|---|
--apexstock-dark-bg | #1e242b | Surface background |
--apexstock-dark-surface-2 | #272e36 | Secondary surface |
--apexstock-dark-bg-alpha | rgba(255,255,255,.04) | Subtle raised fill |
--apexstock-dark-border | #3a434d | Default borders |
--apexstock-dark-border-strong | #4a545f | Hover/emphasis borders |
--apexstock-dark-hover | #2d353e | Hover background |
--apexstock-dark-text | #e6eaf0 | Primary text / icon stroke |
--apexstock-dark-muted | #9aa4b2 | Secondary text |
--apexstock-dark-selected | #2b3a55 | Selected option background |
--apexstock-dark-divider | #3a434d | Toolbar dividers |
--apexstock-dark-shadow | 0 6px 24px rgba(0,0,0,.5) | Dropdown/popup shadow |
Accent (shared by both modes)
| Token | Default | Controls |
|---|---|---|
--apexstock-blue | #2563eb | Primary accent (active tool, focus ring, color swatch) |
--apexstock-blue-hover | #1d4ed8 | Accent hover |
--apexstock-accent-soft | rgba(37,99,235,.1) | Active option background tint |
--apexstock-danger | #dc3545 | Destructive action (clear/delete) |
--apexstock-danger-light | #f8d7da | Destructive hover tint |
--apexstock-success | #28a745 | Success accent |
Sizing & motion (shared)
| Token | Default | Controls |
|---|---|---|
--apexstock-button-size | 32px | Toolbar button square size |
--apexstock-border-radius-sm | 6px | Small radius (buttons, inputs) |
--apexstock-border-radius-md | 8px | Medium radius (controls) |
--apexstock-border-radius-lg | 10px | Large radius (dropdown menus) |
--apexstock-font-size-sm | 10px | Small UI label size |
--apexstock-gap-sm | 5px | Tight gap |
--apexstock-gap-md | 8px | Medium gap |
--apexstock-gap-lg | 10px | Large gap |
--apexstock-as-ease | 0.15s ease | Control transition timing |
A ready-to-edit starting point with every token at its default ships as apexstock/theme-template.css (in dist/themes/apexstock-theme-template.css): copy it, change values, and wrap it in one of the selectors above.