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-series colors), 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:

TokenRole
--apx-accentThe color that means interactive or selected
--apx-foreText and anything that must stay legible on the surface
--apx-gridHairlines: borders, gridlines, dividers
--apx-surfaceThe plane content sits on
--apx-series-1 ... --apx-series-NAn ordered categorical palette (1-based), read by the charts through ApexCharts
--apx-font-familyThe 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)

TokenDefaultControls
--apexstock-light-bg#ffffffSurface background (toolbar controls, dropdowns)
--apexstock-light-surface-2#f8fafcSecondary surface
--apexstock-light-border#e4e7ecDefault borders
--apexstock-light-border-strong#d0d5ddHover/emphasis borders
--apexstock-light-hover#f2f4f7Hover background
--apexstock-light-text#1f2937Primary text / icon stroke
--apexstock-light-muted#667085Secondary text
--apexstock-light-selected#eef4ffSelected option background
--apexstock-light-divider#e4e7ecToolbar dividers
--apexstock-light-shadow0 6px 24px rgba(16,24,40,.14)Dropdown/popup shadow

Dark palette (apexstock-theme-dark)

TokenDefaultControls
--apexstock-dark-bg#1e242bSurface background
--apexstock-dark-surface-2#272e36Secondary surface
--apexstock-dark-bg-alphargba(255,255,255,.04)Subtle raised fill
--apexstock-dark-border#3a434dDefault borders
--apexstock-dark-border-strong#4a545fHover/emphasis borders
--apexstock-dark-hover#2d353eHover background
--apexstock-dark-text#e6eaf0Primary text / icon stroke
--apexstock-dark-muted#9aa4b2Secondary text
--apexstock-dark-selected#2b3a55Selected option background
--apexstock-dark-divider#3a434dToolbar dividers
--apexstock-dark-shadow0 6px 24px rgba(0,0,0,.5)Dropdown/popup shadow

Accent (shared by both modes)

TokenDefaultControls
--apexstock-blue#2563ebPrimary accent (active tool, focus ring, color swatch)
--apexstock-blue-hover#1d4ed8Accent hover
--apexstock-accent-softrgba(37,99,235,.1)Active option background tint
--apexstock-danger#dc3545Destructive action (clear/delete)
--apexstock-danger-light#f8d7daDestructive hover tint
--apexstock-success#28a745Success accent

Sizing & motion (shared)

TokenDefaultControls
--apexstock-button-size32pxToolbar button square size
--apexstock-border-radius-sm6pxSmall radius (buttons, inputs)
--apexstock-border-radius-md8pxMedium radius (controls)
--apexstock-border-radius-lg10pxLarge radius (dropdown menus)
--apexstock-font-size-sm10pxSmall UI label size
--apexstock-gap-sm5pxTight gap
--apexstock-gap-md8pxMedium gap
--apexstock-gap-lg10pxLarge gap
--apexstock-as-ease0.15s easeControl 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.