API Reference

Complete reference for all components, props, and types.

KlineChart Component

The main component for rendering candlestick charts.

usage.tsx
<KlineChart
  data={candles}
  width={screenWidth}
  height={450}
  candleWidth={8}
  candleSpacing={3}
  showMA={true}
  maPeriods={[5, 10]}
  showCrosshair={true}
  onCrosshairChange={(candle) => console.log(candle)}
/>

Props

PropTypeDefaultRequiredDescription
dataCandle[]YesArray of candle data to render
widthnumberYesChart canvas width in pixels
heightnumberYesChart canvas height in pixels
candleWidthnumber8NoWidth of each candle body
candleSpacingnumber3NoSpace between candles
minCandleWidthnumber2NoMinimum candle width when zoomed out
maxCandleWidthnumber24NoMaximum candle width when zoomed in
bullishColorstring'#2DC08E'NoColor for bullish candles (close >= open)
bearishColorstring'#F6465D'NoColor for bearish candles (close < open)
showMAbooleantrueNoWhether to show Moving Average lines
maPeriodsnumber[][5, 10]NoMA calculation periods
maColorsstring[]['#F7931A', '#5B8DEF', '#C084FC']NoColors for each MA line
showCrosshairbooleantrueNoEnable long-press crosshair
backgroundColorstring'#0B0E11'NoChart background color
gridColorstring'rgba(255,255,255,0.2)'NoGrid line color
textColorstring'rgba(255,255,255,0.35)'NoAxis label text color
crosshairColorstring'rgba(255,255,255,0.3)'NoCrosshair line color
rightPaddingCandlesnumber20NoRight-side padding in candle units
onCrosshairChange(candle: Candle | null) => voidNoCallback when crosshair activates or deactivates

Exports

Everything exported from the package:

imports.ts
import { KlineChart, computeMA } from 'react-native-kline-chart';
import type { Candle, KlineChartProps } from 'react-native-kline-chart';