Skip to content

Theming

Every color, font, and the up/down palette come from one plain object: the chart’s theme. Pass a Partial<ChartTheme> at creation and it’s merged over DEFAULT_THEME, so you only set what you want to change:

import { createChart } from '@lightfin/core'
const chart = createChart(container, {
theme: {
upColor: '#2e7d32',
downColor: '#c62828',
lineColor: '#5c6bc0',
},
})

The engine has no live option setter — to change the theme after creation, re-create the chart with the new theme.

Every field of ChartTheme, its type, its default, and what it paints:

PropertyTypeDefaultDescription
backgroundstring#131722Pane fill behind the plot; its lightness also decides the chrome’s light/dark scheme.
gridColorstring#1f2733Horizontal/vertical grid line color.
axisTextColorstring#9db2bdAxis strip text + tick color.
axisBorderColorstring#2a2e39Hairline color for axis borders.
upColorstring#26a69aUp (bullish) candle/bar body + wick.
downColorstring#ef5350Down (bearish) candle/bar body + wick.
volumeUpColorstringrgba(38, 166, 154, 0.5)Volume histogram fill for up bars; usually semi-transparent so candles read through.
volumeDownColorstringrgba(239, 83, 80, 0.5)Volume histogram fill for down bars.
lineColorstring#2962ffStroke for the line and area chart types (and their current-price line).
areaTopColorstringrgba(41, 98, 255, 0.28)Area chart gradient fill. areaTopColor is at the top of the pane; areaBottomColor is reached about a volume-bar’s height above the bottom and held to the edge (default fully transparent).
areaBottomColorstringrgba(41, 98, 255, 0)—
crosshairColorstring#758696Crosshair hairline color.
fontFamilystring-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serifFont stack for all chart text — axis labels, crosshair, legend.
fontSizenumber11Base font size in px for chart text.
indicatorPalettestring[]#2962ff #ff6d00 #7e57c2 #26a69a #ec407a #9ccc65Default colors assigned to indicator plots in the order they’re added, cycled when more indicators are added than colors in the list. Only applies to a plot whose indicator didn’t receive an explicit color in its options — an explicit color/macdColor/etc. always wins.

15 theme properties. Defaults are from DEFAULT_THEME; pass any subset as theme and the rest fall back to it.

Colors accept any CSS color string the canvas understands — #rgb, #rrggbb, rgb()/rgba(). The volume* and area* defaults are intentionally semi-transparent so the candles and gridlines read through them.

There’s no separate light/dark switch — a light theme is just a theme whose background is light. The chrome reads that lightness to flip its own scheme (see below), so one object does both:

createChart(container, {
theme: {
background: '#ffffff',
gridColor: '#f0f3fa',
axisTextColor: '#50545e',
axisBorderColor: '#e0e3eb',
crosshairColor: '#9598a1',
},
})

If you use the chrome toolbars, you don’t theme them separately. It derives a set of --lf-* CSS custom properties from the chart theme and sets them on the host element, so the toolbars, menus, and dialogs stay in sync:

CSS variableDerived from
--lf-bgbackground
--lf-textaxisTextColor
--lf-text-strongpicked from background lightness
--lf-borderaxisBorderColor
--lf-accentlineColor
--lf-upupColor
--lf-downdownColor
--lf-fontfontFamily

The widgets also set color-scheme from the same lightness check, so native controls (scrollbars, range sliders) match. You can override any --lf-* variable in your own CSS if you need the chrome to diverge from the plot.

indicatorPalette is handed out round-robin as you add indicators, so a fresh chart’s indicators are distinct without any per-indicator config. An explicit color in an indicator’s options always wins — see Indicators → Colors.