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 |
timeframes | string[] | — | Available timeframe options |
activeTimeframe | string | — | Currently selected timeframe |
onTimeframeChange | (tf: string) => void | — | Timeframe change handler |
height | number | 256 | Chart height in pixels |
showGrid | boolean | true | Show grid lines |
bullColor | string | 'emerald-500' | Color for bullish candles |
bearColor | string | 'rose-500' | Color for bearish candles |
Usage
Import and implementation examples
// Define candle data (OHLC)
const candles = [
{ open: 45, close: 60, high: 70, low: 40 }, // green (bullish)
{ open: 60, close: 50, high: 65, low: 45 }, // red (bearish)
{ open: 50, close: 65, high: 75, low: 48 }, // green
]
// Render candlesticks
{candles.map((candle, i) => {
const isGreen = candle.close > candle.open
const bodyTop = Math.max(candle.open, candle.close)
const bodyBottom = Math.min(candle.open, candle.close)
const bodyHeight = bodyTop - bodyBottom
const wickTop = candle.high - bodyTop
const wickBottom = bodyBottom - candle.low
return (
<div key={i} className="flex flex-col items-center">
{/* Upper wick */}
<div style={{ height: `${wickTop}%`, backgroundColor: isGreen ? 'green' : 'red' }} />
{/* Body */}
<div style={{ height: `${bodyHeight}%`, backgroundColor: isGreen ? 'green' : 'red' }} />
{/* Lower wick */}
<div style={{ height: `${wickBottom}%`, backgroundColor: isGreen ? 'green' : 'red' }} />
</div>
)
})}Features
Built-in functionality
- OHLC data: Shows open, high, low, close prices per period
- Color coding: Green for bullish, red for bearish movements
- Timeframe selection: Switch between different time periods
- Grid lines: Optional dashed grid for value reading
- Hover states: Interactive candle highlighting
- Dark mode: Full dark mode support
Accessibility
Accessibility considerations
ARIA Attributes
Chart container has role="img"aria-label describes the data rangeTimeframe tabs are keyboard navigableKeyboard 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