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.
Theme variables
Section titled “Theme variables”Every field of ChartTheme, its type, its default, and what it paints:
| Property | Type | Default | Description |
|---|---|---|---|
background | string | #131722 | Pane fill behind the plot; its lightness also decides the chrome’s light/dark scheme. |
gridColor | string | #1f2733 | Horizontal/vertical grid line color. |
axisTextColor | string | #9db2bd | Axis strip text + tick color. |
axisBorderColor | string | #2a2e39 | Hairline color for axis borders. |
upColor | string | #26a69a | Up (bullish) candle/bar body + wick. |
downColor | string | #ef5350 | Down (bearish) candle/bar body + wick. |
volumeUpColor | string | rgba(38, 166, 154, 0.5) | Volume histogram fill for up bars; usually semi-transparent so candles read through. |
volumeDownColor | string | rgba(239, 83, 80, 0.5) | Volume histogram fill for down bars. |
lineColor | string | #2962ff | Stroke for the line and area chart types (and their current-price line). |
areaTopColor | string | rgba(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). |
areaBottomColor | string | rgba(41, 98, 255, 0) | — |
crosshairColor | string | #758696 | Crosshair hairline color. |
fontFamily | string | -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif | Font stack for all chart text — axis labels, crosshair, legend. |
fontSize | number | 11 | Base font size in px for chart text. |
indicatorPalette | string[] | #2962ff #ff6d00 #7e57c2 #26a69a #ec407a #9ccc65 | Default 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.
A light theme
Section titled “A light theme”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', },})The chrome follows the theme
Section titled “The chrome follows the theme”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 variable | Derived from |
|---|---|
--lf-bg | background |
--lf-text | axisTextColor |
--lf-text-strong | picked from background lightness |
--lf-border | axisBorderColor |
--lf-accent | lineColor |
--lf-up | upColor |
--lf-down | downColor |
--lf-font | fontFamily |
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.
Indicator colors
Section titled “Indicator colors”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.