Skip to content

Candlestick Chart for React

A React candlestick chart shows prices over time as candles or OHLC bars, with a volume strip and a moving average. Pass data as readonly Candle[]: one candle per period, oldest first.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/candlestick-chart.json

ACME Corp.

Use left and right arrow keys to read each candle, plus and minus to zoom, Shift with the arrows to pan.

  • CandlestickChart
  • CandlestickTable
  • parseCandles
  • defaultCandlestickChartLabels
  • +2 more

Daily candles, volume and a 20-day average

Opens on the last 60 trading days of 160. Zoom out with the buttons or a pinch; drag to pan (two fingers on touch); hover, tap or arrow through the candles. Switch the symbol: the price axis eases to the new range.

ACME Corp.

NASDAQ: ACME · daily

$324.18

Files to copy

16 folders · 35 files · 4 packages
From theme/src/
  • components/charts/{candlestick-chart.tsx, category-bar.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-pointer.tsx, chart-tip.tsx, chart-utils.ts, flow-utils.tsx, heatmap.tsx}
  • components/button/
  • components/charts/candlestick-chart/
  • components/charts/category-bar/
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/spinner/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-intersection.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts, use-resolved-scheme.ts}
  • motion/{gate.ts, tokens.ts}
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, state-light.tsx, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/candlestick-chart.jsonRegistry item: candlestick-chart. The styles need the Tailwind v4 glass UI setup.
The examples also use
  • components/number-ticker/
  • lib/canvas-effects.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/number-ticker.json
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

OHLC bars, intraday

Five-minute bars for one session. OHLC bars put the open tick on the left and the close tick on the right; times replace dates on the axis automatically.

NVLX · Oct 30

5-minute bars, regular session

Props

PropTypeDefaultDescription
data (required)readonly Candle[]NoneOne candle per period, oldest first. Candles with a missing price are skipped.
mode"candle" | "ohlc""candle""candle" (default): bodies and wicks. "ohlc": bars with an open tick (left) and a close tick (right).
volumebooleanwhen any candle has a volumeShow the volume strip under the prices.
averagenumber0Overlay a simple moving average of the close over this many periods (e.g. 20).
heightnumber300Sets the height of the price panel in px.
volumeHeightnumber64Sets the height of the volume strip in px.
upColorChartColorgreen (rising), red (falling)Palette slots for rising and falling candles: green and red that hold >= 3:1 on the chart surface in both themes (slot 6 / 8 in light, the status hues in dark). Rising candles are hollow, falling ones filled.
downColorChartColorNoneSets the palette slot (1 to 8) of falling candles.
averageColorChartColor1Sets the palette slot of the moving average.
format((n: number) => string)2 decimals in localeFormats a price for the axis, tooltip and data table: takes the number, returns the text shown.
formatVolume((n: number) => string)compact in localeFormats a volume figure as text.
formatDate((d: Date) => string)"Thu, Oct 3, 2026" in localeFormats dates (readout, table): "Thu, Oct 3, 2026" in locale, with the time for intraday data.
localestring"en"Locale of the default number and date formats.
timeZonestringthe viewer'sIANA time zone of the default date formats, e.g. the exchange's "America/New_York".
zoombooleantrueZoom (Ctrl/⌘ + scroll, pinch, + / −) and pan (drag, Shift + arrows).
defaultRange[number, number]every candleInitial visible window, as candle indices [start, end).
onRangeChange((range: [number, number]) => void)NoneCalled with the visible window [start, end) whenever it changes.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<CandlestickChartLabels>defaultCandlestickChartLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultCandlestickChartLabels. All 23 keys of CandlestickChartLabels are listed in the key table under the props table.
aria-label (required)stringNoneAccessible summary of what the chart shows.
classNamestringNoneAdds extra classes to the outer element.
CandlestickChartLabels keys and English defaults (23)
Pass any key in labels; the rest keep the defaults of defaultCandlestickChartLabels.
KeyEnglish default
instructionsUse left and right arrow keys to read each candle, plus and minus to zoom, Shift with the arrows to pan.
openopen
highhigh
lowlow
closeclose
volumevolume
openShortO
highShortH
lowShortL
closeShortC
volumeShortVol
upup
downdown
unchangedunchanged
average(n) => `MA ${n}`
zoomInZoom in
zoomOutZoom out
resetZoomShow all
zoomHint(key) => `Hold ${key} and scroll to zoom`
dateDate
changeChange
emptyNo data
showAll(rows) => `Show all ${rows} rows`

CandlestickTable props

PropTypeDefaultDescription
data (required)readonly Candle[]NoneOne candle per period, oldest first. Candles with a missing price are skipped.
format((n: number) => string)2 decimals in localeFormats a price for the axis, tooltip and data table: takes the number, returns the text shown.
labelsPartial<CandlestickChartLabels>defaultCandlestickChartLabelsEvery other string, for translation: labels={{ instructions: "…" }}; omitted keys keep the English of defaultCandlestickChartLabels. All 23 keys of CandlestickChartLabels are listed in the key table under the props table.
localestring"en"Locale of the default number and date formats.
formatVolume((n: number) => string)compact in localeFormats a volume figure as text.
formatDate((d: Date) => string)"Thu, Oct 3, 2026" in localeFormats dates (readout, table): "Thu, Oct 3, 2026" in locale, with the time for intraday data.
timeZonestringthe viewer'sIANA time zone of the default date formats, e.g. the exchange's "America/New_York".
captionstringNoneHidden caption that names the table for screen readers.
order"newest" | "oldest""newest"Sets the sort order: newest first (default), or oldest first.
limitnumber30Rows shown before "Show all" (opening the table stays instant on long histories).

Keyboard

KeysAction
TabFocus the chart, then the zoom buttons.
←/→Previous / next candle; the window follows the active candle.
Home/EndFirst / last candle.
Shift + ←/Shift + →Pan the window.
+/−Zoom in / out around the active candle.
0Show every candle.
EscapeClear the crosshair (the readout returns to the latest candle).

Accessibility

  • The chart is one focusable figure; its description is the keyboard hint. Each candle read by keyboard is announced once: date, open, high, low, close, the move in words (“down 1.68%”), volume and the average.
  • Rising candles are hollow and falling ones filled, and the readout carries an arrow and a sign: color is never the only cue. The default green and red keep 3:1 against the chart in both themes.
  • Volume has its own strip under the prices, on the same time axis: there is never a second y-axis on the price plot.
  • A plain scroll never hijacks the page; Ctrl/⌘ + scroll (or a pinch) zooms, and a hint says so. Zoom buttons are real buttons, 44px on touch.
  • The table view lists every candle with its change, newest first. Reduced motion draws everything in place.

All exports on this page

  • CandlestickChart — Candlesticks (or OHLC bars) for prices over time, with a volume strip, a moving average and a crosshair readout: the chart traders expect.
  • CandlestickTable — Every candle: date, open, high, low, close, change against the previous close, and volume.
  • defaultCandlestickChartLabels — The built-in English strings of CandlestickChart; spread it into your own labels and change what you need.
  • parseCandles — Valid candles with their previous close and the moving average (when asked).

When to use the candlestick chart

  • Use it as a stock chart or crypto price chart (FX works too) where each period has open, high, low and close, plus an optional volume strip and a moving average for trend context.
  • Use ohlc mode for dense daily series where traders prefer bars with open and close ticks over candle bodies, and set timeZone to the exchange's IANA zone so dates read correctly.
  • Let readers explore long histories: zoom with Ctrl or Cmd plus scroll, a pinch, or the plus and minus keys, pan by dragging, and use onRangeChange to sync a range label elsewhere.
  • Skip it when you only have one price per period, such as a closing price series, where a Line chart or Sparkline is simpler and does not imply data you lack.
  • Pair it with ChartCard for the export and table tabs, CandlestickTable for a text view, and SegmentedControl buttons to switch the interval or the visible window.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .