Candlestick Chart
Charts
Trading
OHLC (Open, High, Low, Close) candlestick charts for trading and time-series data visualization.
Preview
Crypto trading chart with timeframe selection
Ethereum
ETH/USD24h High
$3,920
24h Low
$3,850
Live Price
$3,910.72
09:0009:3010:0010:3011:0011:3012:00
Props
Component API reference
| Prop | Type | Default | Description |
|---|---|---|---|
data* | CandleData[] | — | Array of OHLC candle objects |
height | number | 256 | Plot height in pixels |
showGrid | boolean | true | Show dashed grid lines |
showAxis | boolean | false | Show price labels on the y-axis |
padding | number | 0.08 | Fraction of the data range added above and below the plot |
labels | string[] | — | X-axis labels, spread evenly under the plot |
highlightLabel | string | — | X-axis label shown in the primary color |
bullColor | string | 'var(--color-success-default)' | Color for rising candles |
bearColor | string | 'var(--color-danger-default)' | Color for falling candles |
formatValue | (value: number) => string | — | Formats y-axis values and tooltips |
Usage
Import and implementation examples
import { CandlestickChart } from '@/components/ui/candlestick-chart'
const candles = [ { open: 45, close: 60, high: 70, low: 40 }, // bullish { open: 60, close: 50, high: 65, low: 45 }, // bearish { open: 50, close: 65, high: 75, low: 48 },]
// The y-scale is fitted to the data range, so candles fill the plot<CandlestickChart data={candles} labels={['09:00', '10:00', '11:00']} showAxis/>Features
Built-in functionality
- OHLC data: Shows open, high, low, close prices per period
- Color coding: Green for bullish, red for bearish movements
- Fitted y-scale: Scale follows the data range plus padding, so candles fill the plot
- Grid lines: Optional dashed grid for value reading
- Hover states: Interactive candle highlighting
Accessibility
Accessibility considerations
ARIA Attributes
Chart container has role="img"aria-label describes the data rangeEach candle has a native tooltip with its OHLC valuesKeyboard Navigation
| Key | Action |
|---|---|
| Tab | Navigate between timeframe tabs |
| Enter / Space | Select timeframe |
Notes
- Provide data table alternative for screen readers
- Price changes announced with direction
- Color is supplemented with position indicators