Skip to content

Theme

A theme defines the default visual styling for all chart elements. Themes allow you to establish a consistent look across the entire chart without having to configure each element individually. Per-component config props will override theme values when provided.

Example

See the default light theme for a complete example.

Properties

chart

Global chart-level styling.

chart.backgroundColor

  • Type: string

chart.borders

chart.xAxis

chart.grid

chart.crosshairs

panels

Default styling applied to all panels.

layers

Default styling for each layer type.


XAxisTheme

Properties

height

  • Type: number

Height of the x-axis in pixels.

border

minorLabels

  • Type: Omit<TimeLabelConfig, 'formatter'>

majorLabels

  • Type: Omit<TimeLabelConfig, 'formatter'>

BordersTheme

Default

ts
{
  left:   { color: '#ddd', width: 1, style: 'solid' },
  right:  { color: '#ddd', width: 1, style: 'solid' },
  top:    { color: '#ddd', width: 1, style: 'solid' },
  bottom: { color: '#ddd', width: 1, style: 'solid' },
}

Properties

left

top

bottom


GridTheme

Properties

time

Styling for vertical grid lines drawn at each time axis tick.

value

Styling for horizontal grid lines drawn at each value axis tick.


CrosshairsTheme

Properties

time

value


PanelTheme

Properties

paddingTop

  • Type: number

paddingBottom

  • Type: number

borderTop

controls


PanelControlsTheme

Properties

goToLatestButton


YAxisTheme

Default

ts
{
  side: 'right',
  width: 60,
  border: { color: '#ddd', width: 1, style: 'solid' },
  labels: { padding: 6 }
}

Properties

side

  • Type: 'left' | 'right'

Which side of the panel the y-axis is rendered on.

width

  • Type: number

Width of the y-axis in pixels.

border

labels


LegendTheme

Default

ts
{
  left: 12,
  backgroundColor: '#ffffff77',
  borderColor: 'transparent',
  borderWidth: 0,
  vPadding: 1,
  hPadding: 4,
  borderRadius: 0,
  label: ''
}

Properties

Extends LegendConfig (excluding fields).

fields


LegendFieldTheme

Properties

output

  • Type: string

The output key of the layer value to display.

color

  • Type: string

The text color for this field's value.

label

  • Type: string

An optional label override.


LayersTheme

Defines default styling for each built-in layer type. Each key corresponds to a layer type and its associated theme interface.

KeyTheme type
candlesticksCandlesticksTheme
priceLinePriceLineTheme
volumeBarsVolumeBarsTheme

| sma | SmaTheme | | stochastic | StochasticTheme |


CandlesticksTheme

Properties

series

  • Type: { body: DirectionalBarConfig; wick: DirectionalLineConfig }

Styling for candlestick body and wick.

markers

  • Type: { value: DirectionalValueMarkerTheme }

legend

yAxis


DirectionalValueMarkerTheme

Properties

up

down

flat


PriceLineTheme

Properties

series

  • Type: { value: LineConfig }

markers

  • Type: { value: ValueMarkerConfig }

legend

yAxis


VolumeBarsTheme

Properties

series

  • Type: { bars: DirectionalBarConfig }

markers

  • Type: { value: ValueMarkerConfig }

legend

yAxis


SmaTheme

Properties

series

  • Type: { value: LineConfig }

markers

  • Type: { value: ValueMarkerConfig }

legend

yAxis


StochasticTheme

Properties

series

  • Type: { k: LineConfig; d: LineConfig }

Styling for the %K and %D lines.

markers

  • Type: { k: ValueMarkerConfig; d: ValueMarkerConfig }

legend

yAxis


TypeScript

ts
interface Theme {
  chart: {
    backgroundColor: string;
    xAxis: XAxisTheme;
    borders: BordersTheme;
    grid: GridTheme;
    crosshairs: CrosshairsTheme;
  };
  panels: PanelTheme;
  layers: LayersTheme;
}

interface XAxisTheme {
  height: number;
  border: LineConfigComplete;
  minorLabels: Omit<TimeLabelConfigComplete, 'formatter'>;
  majorLabels: Omit<TimeLabelConfigComplete, 'formatter'>;
}

interface BordersTheme {
  left: LineConfigComplete;
  right: LineConfigComplete;
  top: LineConfigComplete;
  bottom: LineConfigComplete;
}

interface GridTheme {
  time: LineConfigComplete;
  value: LineConfigComplete;
}

interface CrosshairsTheme {
  time: TimeCrosshairTheme;
  value: ValueCrosshairTheme;
}

interface PanelTheme {
  paddingTop: number;
  paddingBottom: number;
  borderTop: LineConfigComplete;
  controls: PanelControlsTheme;
}

interface PanelControlsTheme {
  goToLatestButton: ButtonTheme;
}

interface YAxisTheme {
  side: 'left' | 'right';
  width: number;
  border: LineConfigComplete;
  labels: ValueLabelConfigComplete;
}

interface LegendTheme extends Omit<LegendConfigComplete, 'fields'> {
  fields: LegendFieldTheme[];
}

interface LegendFieldTheme {
  output: string;
  color: string;
  label?: string;
}

interface LayersTheme {
  candlesticks: CandlesticksTheme;
  priceLine: PriceLineTheme;
  volumeBars: VolumeBarsTheme;
  atr: AtrTheme;
  bollingerBands: BollingerBandsTheme;
  ema: EmaTheme;
  macd: MacdTheme;
  rsi: RsiTheme;
  sma: SmaTheme;
  stochastic: StochasticTheme;
}

interface CandlesticksTheme {
  series: {
    body: DirectionalBarTheme;
    wick: DirectionalLineTheme;
  };
  markers: {
    value: DirectionalValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface DirectionalValueMarkerTheme {
  up: ValueMarkerTheme;
  down: ValueMarkerTheme;
  flat: ValueMarkerTheme;
}

interface PriceLineTheme {
  series: {
    value: LineConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface VolumeBarsTheme {
  series: {
    bars: DirectionalBarConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface AtrTheme {
  series: {
    value: LineConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface BollingerBandsTheme {
  series: {
    middle: LineConfigComplete;
    upper: LineConfigComplete;
    lower: LineConfigComplete;
  };
  bands: {
    channel: {
      fillColor: string;
    };
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface EmaTheme {
  series: {
    value: LineConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface MacdTheme {
  series: {
    macd: LineTheme;
    signal: LineTheme;
    histogramUp: BarConfigComplete;
    histogramDown: BarConfigComplete;
  };
  markers: {
    macd: ValueMarkerTheme;
    signal: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface RsiTheme {
  series: {
    value: LineConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface SmaTheme {
  series: {
    value: LineConfigComplete;
  };
  markers: {
    value: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

interface StochasticTheme {
  series: {
    k: LineTheme;
    d: LineTheme;
  };
  markers: {
    k: ValueMarkerTheme;
    d: ValueMarkerTheme;
  };
  legend: LegendTheme;
  yAxis: YAxisTheme;
}

React Candlesticks is available on npm and GitHub under the MIT License.