Components

Chart

Charts drawn by hand: bars colored in with a marker, felt lines, pencil-shaded areas, pies, radars, dials, sparklines, tally marks and calendar heat maps. Real text on a real DOM, a keyboard cursor, a tooltip on a slip of paper, a legend that switches series off, a table for screen readers, and a pencil pattern on every series so color is never the only channel.

Install

terminal
npx shadcn@latest add @wobko/chart

First time here? Add the registry to components.json first. How to install

Examples

Bar chart

Bars colored in with a marker that misses the outline a little, numbers on top, and the best day circled by hand. Hover or press the arrow keys: a highlighter lights the column and a slip of paper names it.

Grouped, stacked, sideways

One dataset, four ways to lay it out. Each series keeps its color and its pencil pattern (hatching, dots, cross-hatching), so the bars stay apart in grayscale. Negative values hang below the line.

Line chart

A felt line per series, with a marker shape and a dash pattern for each so lines survive black-and-white print. The legend switches series off; the tooltip follows the pointer and the arrow keys.

Area chart

The space under the line is washed with the series color and shaded in pencil: hatching, dots, cross-hatching. Stacked areas add up; the tooltip lists every layer.

Pie and donut

Slices colored in with a marker, separated by felt lines, each with its own pencil pattern. The donut's hole is DOM text: it shows the total, and the slice under the pointer or the arrow keys.

Radar chart

A pencil web with a washed and shaded shape per series. The spokes are the keyboard stops: arrow keys walk from axis to axis and the tooltip reads every series on that spoke.

Radial bars and gauge

Concentric arcs in pale tracks, one ring per row, and a dial with marker zones and a red felt needle. The gauge is a role=meter: assistive tech reads its value, minimum and maximum.

Sparklines

One felt pull and a red dot at the end, a shaded area, or a row of marker bars. A sparkline is a picture with a spoken summary; set interactive to make it a chart you can hover.

Heat map

A half year of days, each square colored in a shade of one marker; or any grid of your own. Arrow keys walk it in two dimensions: left and right by week, up and down by day.

Tally chart

Counts as hand-tallied marks: four uprights and a slash across for every five, in the color of the row. When a row is too long for the width, each mark starts to stand for more and says so.

Scatter and bubbles

Points on two number lines, each series with its own marker shape (circle, square, triangle). Give a size key and the points grow into bubbles. Long point clouds are thinned so the drawing stays light.

Annotations and goal lines

A note is a hand-drawn loop, an arrow and a line of script; a highlight marks a stretch of days with a highlighter, written after the chart appears. Point it at max, min, first, last, a category or an index; underline instead of circling; add a dashed goal line. Text is real DOM text and the note is part of the chart's spoken summary.

Legend and hidden series

Every legend entry is a button with aria-pressed: switch a series off (struck through) and on again. A series keeps its color, marker and dash while it is away. Control it from outside with hiddenSeries.

Dashboard

A page of cards: stat tiles with sparklines, an area chart, a bar chart and a donut, drawn by hand. Press "calm" for the dense-screen version: hairline rules, no fill offset, no jitter, a busy page that stays quiet.

Streaming data

New points arrive every second and the chart is drawn again, not reflowed: the hand stays the same, so the line seems to move by itself. The wipe-on animation plays once; a redraw is silent. Pause to read the tooltip.

Empty and loading

A chart with nothing to draw sketches its axes and a wandering pencil line and says so; a loading chart pulses dashed ghost bars and is aria-busy. Neither is interactive, and both keep their name and a spoken summary.

Tooltip content

ChartTooltipContent keeps shadcn's props: indicator (dot, line, dashed), hideLabel, hideIndicator, labelFormatter and formatter. Or pass any element as content: it is cloned with active, payload and label. defaultIndex opens a tooltip on load.

Color is not the only channel

Every series carries a pencil pattern (hatching, dots, cross-hatching, rules, scribble) on its marks, and a marker shape and a dash pattern on its lines. Switch to grayscale to see the chart still reads; switch the patterns off (`patterns={false}`) to see what plain color would have left you.

Area: default

One series washed in marker and shaded in pencil, a felt line along the top. Hover or use the arrow keys: the tooltip's `indicator="line"` gives it a bar instead of a chip, and a hand-drawn note points at the peak. The axis says Jan; `labelFormatter` reads the whole month from the row for the slip.

Area: linear

`curve="linear"` joins the points with straight pencil strokes instead of the default smooth curve. The tooltip drops its label with `hideLabel`.

Area: step

`curve="step"` holds each value until the next category, like a ledger. A config `icon` replaces the swatch in the tooltip and the legend.

Area: stacked to 100%

Each month scaled to its own total, so the layers show shares. The rows are turned into percentages first (`visitorsShare` in `_data.ts`), then stacked with `yDomain={[0, 100]}`; the axis gets its % from `yFormatter`.

Area: stacked

`stacked` piles the series on top of each other; `series` sets the order from the bottom up. Each keeps its own wash and pencil pattern, so the layers stay apart in grayscale.

Area: legend

`<ChartLegend />` lists the series with the very swatches the drawing uses. Every entry is a button: switch a series off and it is struck through and leaves the chart.

Area: overlapping

Without `stacked` the series are drawn over each other from zero, each with its own wash, so a smaller series shows through the bigger one. The tooltip lists both.

Area: axes

Both axes drawn: the category names along the bottom, a few tidy ticks up the side, and broken pencil rules across. `showXAxis` and `showYAxis` switch either off.

Area: icons

A config `icon` stands in for the swatch in the legend and the tooltip. Here they are the two hand-drawn trend arrows.

Area: interactive

A Select in the card header picks how much of the ninety-one days to draw. The chart redraws with its new data and stays quiet: the wipe-on plays once. Dates are cut from the row's own text, so nothing depends on a locale or a time zone.

Bar: default

Bars colored in with a marker that misses the outline a little, the number on top of each, and the best month circled by hand. `tape` holds the card to the desk.

Bar: horizontal

`horizontal` turns the bars sideways: categories down the left, the value along the bottom. The arrow keys walk the rows with up and down.

Bar: mixed

A color and a pencil pattern for every bar. One column per browser (`browserColumns` in `_data.ts`), stacked, gives each category its own series, so the tooltip and the table name it too.

Bar: multiple

Several series side by side in each category. Color is never the only channel: the second series is shaded with a different pencil pattern. The tooltip's `indicator="dashed"` marks its rows with a dashed rule.

Bar: stacked + legend

`stacked` piles the bars up; the legend under the chart switches a series off and the rest close ranks.

Bar: active

One bar picked out: a highlighter swipe behind Firefox (`highlights`), and `defaultIndex` opens its tooltip before anyone touches the chart.

Bar: label

`showValues` writes the number on top of every bar, in the script hand. With `auto` (the default) they appear only when they fit.

Bar: negative

Values below zero hang from the baseline. To color the gains and the losses apart the rows are split into two columns (`swingColumns` in `_data.ts`) and stacked, so each sign gets its own color and pencil pattern.

Bar: interactive

Two big buttons total the columns and choose which one the chart draws. They are ordinary toggle buttons with `aria-pressed`; the chart takes the chosen key as its only series.

Line: default

One felt-tip pull through the points, smoothed so it never overshoots a peak. `dots={false}` leaves the markers out; the hand-written note circles the dip. A paper clip holds the card.

Line: linear

`curve="linear"` draws straight segments between the points, like a ruler and a felt tip.

Line: step

`curve="step"` holds each value until the next category, then jumps.

Line: multiple

Two lines, told apart by more than color: each series gets its own dash pattern (solid, dashed, dotted). Try the grayscale example if you doubt it.

Line: custom dots

The marker shape is a config choice per series: circle, square, triangle, diamond, cross or plus. Here desktop is drawn with diamonds and mobile with squares, and the legend shows the same little line sample.

Line: dots

`dots` puts a hand-drawn marker on every point. With `dots="auto"` (the default) they appear when there are few points and room for them.

Line: interactive

The same two-button header as the bar version; the chart draws the chosen key as a single line. Dates on the axis are cut from the row's text, with no locale or time zone involved.

Pie: simple

Slices colored in with a marker, outlined in felt, each shaded with its own pencil pattern. Arrow keys walk the slices. `showLabels={false}` leaves the percentages off.

Pie: label

The default: every slice is labeled with its share, written round the outside in the script hand.

Pie: legend

`<ChartLegend />` names the slices with the swatches the drawing uses, and each entry switches its slice off; the pie redraws from the rest.

Pie: donut, active slice

`defaultIndex` lights the first slice before anyone hovers, and the hole tells its story. Move over another slice, or use the arrow keys, and the light and the text follow.

Pie: donut, text

The hole is real DOM text: a number in the script hand and a caption. Here it is the total; a function of `{ total, active }` can show the slice under the pointer instead.

Pie: donut

`DonutChart` is a pie with a hole (`innerRadius` 0.58 of the radius).

Pie: interactive

A Select in the header chooses the month whose slice is lit (`defaultIndex`); the number in the hole follows. `defaultIndex` is read when the chart mounts, so the chart is keyed on the month and draws itself again. Hovering any slice still takes over.

Radar: default

A pencil web with one shaded shape. The spokes are the keyboard stops: left and right walk the axes. A staple holds the card.

Radar: dots

`dots` marks every vertex with a hand-drawn marker (the default is on).

Radar: lines only

`fill={false}` draws the outlines and nothing else, which keeps two close series readable.

Radar: multiple

Two shapes on one web, each washed in its color and shaded with its own pencil pattern.

Radar: icons

A config `icon` stands in for the swatch in the legend and the tooltip.

Radar: legend

The legend switches a shape off and the web redraws with the other one.

Radar: radius axis

The rings carry their values (`levels` sets how many, `max` where the rim is), written in the gap between the first two spokes in the script hand, so the web reads like a radius axis.

Radial: grid

`startAngle` and `endAngle` set the sweep: here a full circle, so every ring sits in its pale track like a polar grid.

Radial: simple

One ring per row, filled to its value against `max`. On the default three-quarter dial the ring names sit in the open quadrant, in the script hand.

Radial: shape

One ring on a three-quarter dial with its number in the middle: 1,260 visitors against a goal of 1,500. The hole is DOM text, so it can hold anything.

Radial: text

A full circle filled to 80%: 200 of 250. Text in the hole, and the tooltip says how much of the goal is done.

Tooltip: default

The default `ChartTooltipContent`: a label in the script hand, then a row per series with a swatch identical to the drawing. `defaultIndex` opens it on the second bar before anything is hovered.

Tooltip: dashed indicator

`indicator="dashed"` marks each row with a dashed pencil rule instead of a swatch.

Tooltip: line indicator

`indicator="line"` gives each row a narrow bar in the series color and pencil pattern.

Tooltip: no indicator

`hideIndicator` leaves the swatches out; the rows keep the series names.

Tooltip: label from the config

`labelKey` looks the label up in the chart config instead of using the category: here the config's `activities` entry titles the slip.

Tooltip: label formatter

`labelFormatter` turns the label into something to read: 2024-07-16 becomes July 16, 2024. It receives the label and the tooltip rows, and each row carries its data, so the whole date can be read from there.

Tooltip: no label

`hideLabel` drops the category name, and `hideIndicator` the swatches: a bare list of values.

Tooltip: formatter

`formatter` replaces a whole row. It gets the value, the series name, the item and the row of data, and returns any markup, here a unit after the number.

Tooltip: icons

A config `icon` takes the place of the swatch in the tooltip (and in a legend, if there is one).

Tooltip: advanced

A custom formatter that draws the swatch itself with `ChartSwatch` (the same chip the drawing uses) and adds a total row under the last series.

Legend: some of the series

`keys` lists only these entries, in this order: the chart draws three series, the key names two of them, mobile first.

Legend: a plain key

`toggle={false}` makes the legend a plain key: swatches and words, no buttons. Use it where the chart should not change.

Legend: on top

Put `<ChartLegend verticalAlign="top" />` before the chart and it sits above it, with its padding on the side that faces the drawing.

API reference

ChartContainer

The frame around a chart and its legend and tooltip. Same job as shadcn's: it owns the config and puts the series colors on the frame as `--color-<key>` (a `theme` gives a light and a dark value). It also owns which series are switched off. The drawing is not recharts: every chart component in this file draws itself with the ink engine.

PropTypeDefaultDescription
configChartConfig-`{ desktop: { label: 'Desktop', color: 'var(--chart-1)' } }`. A key's position is its palette slot (`--chart-1` is the marker orange, then blue felt, green pencil, deep highlighter, grape). Add `pattern`, `marker` and `dash` to override the look a series gets.
patternsboolean | "auto"solid, patterns in forced colorsSolid color by default. `"auto"` adds pencil patterns on filled marks and dashes on lines when there is more than one series, `true` always does. With no value, patterns switch on by themselves when the system forces its own colors.
hiddenSeriesstring[]-Series (or slices) switched off, controlled. The legend buttons toggle them.
defaultHiddenSeriesstring[]-Uncontrolled start value.
onHiddenSeriesChange(hidden: string[]) => void-A legend button was pressed.
initialDimension{ width: number; height: number }-Draw at this size on the server and before the first measure, so the chart is part of the server HTML.
classNamestring-Sizes the frame: `aspect-auto h-64 w-full`. It is `aspect-video` by default, like shadcn's. A chart takes its size from the frame, so give it a height or a ratio: `aspect-auto` with no height is 0 px tall.

ChartStyle

The `<style>` that carries `--color-<key>` for each config entry (light and `.dark`). ChartContainer renders it for you.

PropTypeDefaultDescription
idstring-The container's `data-chart` value.
configChartConfig-The config to write out.

ChartTooltip

Switches the tooltip on. It renders nothing itself: the chart draws the tooltip inside its own box, where the point is, and keeps it in view. Hover, touch and the arrow keys all move it.

PropTypeDefaultDescription
contentReactElement<ChartTooltipContent />Cloned with `active`, `payload` and `label`. Any component that takes those works.
defaultIndexnumber-Show this data point when nothing is hovered or focused.
cursorbooleantrueKept for shadcn parity. The highlighter behind a column and the ring on a point are part of the drawing.

ChartTooltipContent

The slip of paper: a label in the script font and one row per series with a swatch that matches the drawing (color, pattern, marker). Same props as shadcn's; the payload is recharts-shaped so an existing `formatter` keeps working.

PropTypeDefaultDescription
indicator"dot" | "line" | "dashed""dot"The swatch: a chip (a line swatch for line series), a narrow bar, or a dashed rule.
hideLabelbooleanfalseLeave out the label.
hideIndicatorbooleanfalseLeave out the swatches.
labelFormatter(label: ReactNode, payload: ChartTooltipItem[]) => ReactNode-Change the label.
formatter(value, name, item, index, payload) => ReactNode-Replace a whole row.
nameKey / labelKeystring-Which payload key names a row / the label in the config.
colorstring-Force the indicator color.
className / labelClassNamestring-Merged onto the slip / the label.

ChartLegend

The key of the chart in this container. Place it before (`verticalAlign="top"`) or after the chart. It shows the series the chart registered, with the very swatches the drawing uses.

PropTypeDefaultDescription
contentReactElement<ChartLegendContent />Custom legend markup.
verticalAlign"top" | "bottom""bottom"Which side gets the padding.
keysstring[]-Only these entries, in this order.
togglebooleantrueEntries are buttons (aria-pressed) that switch a series off and on. `false` makes a plain key.

ChartLegendContent

The default legend body; same props as ChartLegend without `content`. `hideIcon` drops the config icon or swatch.

PropTypeDefaultDescription
hideIconbooleanfalseLeave out the swatch / icon.

ChartSwatch

The little chip of a legend or tooltip row: the series' marker fill, its pencil pattern, in a tiny felt box (`line` draws a line sample with its marker and dash).

PropTypeDefaultDescription
palettenumber-The series' slot (its position in the config).
pattern"solid" | "hatch" | "dots" | "cross" | "lines" | "scribble""solid"The pencil pattern.
markerMarkerShape-Line swatches: the marker on the sample.
lineboolean-A line sample instead of a filled chip.

ChartCenterLabel

The words in the hole of a donut or radial chart: a big number in the script font and a small caption. `centerLabel` takes one, a node, or a function of the total and the slice under the cursor.

PropTypeDefaultDescription
valueReactNode-The big text.
labelReactNode-The caption.

BarChart

Bars: single, grouped, stacked or sideways, with negative values hanging below the line. Bars are filled edge to edge in solid color, with a steady felt outline rounded at the far end. The highest bar can be circled by hand.

PropTypeDefaultDescription
horizontalbooleanfalseBars run sideways, categories down the left (ignored when a series is not a bar).
layout"horizontal" | "vertical"-recharts' name for the same thing: "vertical" runs the bars sideways.
dataRecord<string, unknown>[]-One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so.
xKeystring-The category key (a scatter's x number). Default: the first key whose value is text.
seriesstring[]-Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data.
kindsRecord<string, "bar" | "line" | "area" | "scatter">-Mix marks: `{ revenue: "bar", target: "line" }`.
stackedbooleanfalseStack bars (or areas). Positive values stack up from zero, negative ones down.
curve"smooth" | "linear" | "step""smooth"How lines and areas join their points. Smooth is monotone: it never overshoots a peak.
yDomain[number | "auto", number | "auto"]-Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false.
zeroboolean-Whether the value axis includes zero. Default: yes for bars and areas, no for lines.
xFormatter(value: unknown, index: number) => string-Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value.
yFormatter(value: number) => string-Text of an axis tick. Default: compact numbers (1.2k, 3.4M).
valueFormatter(value: number) => string-Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234.
dotsboolean | "auto""auto"Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape.
showValuesboolean | "auto""auto"Numbers on top of bars: drawn when they fit (wide enough, not stacked).
showGridbooleantrueBroken pencil rules across the plot.
showXAxis / showYAxisbooleantrueAxis labels (the baseline is always drawn).
annotationsChartAnnotation[]-Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none.
referencesChartReference[]-Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`).
highlightsChartHighlight[]-A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary.
labelstring-The chart's accessible name and the start of its summary.
descriptionstring-One more sentence for the spoken summary.
xLabelstring-Name of the category column in the data table.
loadingboolean-Ghost bars pulse, the chart is aria-busy and not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it.
seedstring | number-Pins the hand.
accessibilityLayerboolean-Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point (drill down, filter).
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

LineChart

A felt line per series, with a marker shape and a dash pattern each so lines survive grayscale. Gaps in the data break the line. Long series keep their peaks and dips.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so.
xKeystring-The category key (a scatter's x number). Default: the first key whose value is text.
seriesstring[]-Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data.
kindsRecord<string, "bar" | "line" | "area" | "scatter">-Mix marks: `{ revenue: "bar", target: "line" }`.
stackedbooleanfalseStack bars (or areas). Positive values stack up from zero, negative ones down.
curve"smooth" | "linear" | "step""smooth"How lines and areas join their points. Smooth is monotone: it never overshoots a peak.
yDomain[number | "auto", number | "auto"]-Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false.
zeroboolean-Whether the value axis includes zero. Default: yes for bars and areas, no for lines.
xFormatter(value: unknown, index: number) => string-Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value.
yFormatter(value: number) => string-Text of an axis tick. Default: compact numbers (1.2k, 3.4M).
valueFormatter(value: number) => string-Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234.
dotsboolean | "auto""auto"Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape.
showValuesboolean | "auto""auto"Numbers on top of bars: drawn when they fit (wide enough, not stacked).
showGridbooleantrueBroken pencil rules across the plot.
showXAxis / showYAxisbooleantrueAxis labels (the baseline is always drawn).
annotationsChartAnnotation[]-Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none.
referencesChartReference[]-Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`).
highlightsChartHighlight[]-A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary.
labelstring-The chart's accessible name and the start of its summary.
descriptionstring-One more sentence for the spoken summary.
xLabelstring-Name of the category column in the data table.
loadingboolean-Ghost bars pulse, the chart is aria-busy and not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it.
seedstring | number-Pins the hand.
accessibilityLayerboolean-Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point (drill down, filter).
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

AreaChart

Lines with the space under them washed in the series color and shaded in pencil. Stack them with `stacked`.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so.
xKeystring-The category key (a scatter's x number). Default: the first key whose value is text.
seriesstring[]-Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data.
kindsRecord<string, "bar" | "line" | "area" | "scatter">-Mix marks: `{ revenue: "bar", target: "line" }`.
stackedbooleanfalseStack bars (or areas). Positive values stack up from zero, negative ones down.
curve"smooth" | "linear" | "step""smooth"How lines and areas join their points. Smooth is monotone: it never overshoots a peak.
yDomain[number | "auto", number | "auto"]-Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false.
zeroboolean-Whether the value axis includes zero. Default: yes for bars and areas, no for lines.
xFormatter(value: unknown, index: number) => string-Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value.
yFormatter(value: number) => string-Text of an axis tick. Default: compact numbers (1.2k, 3.4M).
valueFormatter(value: number) => string-Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234.
dotsboolean | "auto""auto"Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape.
showValuesboolean | "auto""auto"Numbers on top of bars: drawn when they fit (wide enough, not stacked).
showGridbooleantrueBroken pencil rules across the plot.
showXAxis / showYAxisbooleantrueAxis labels (the baseline is always drawn).
annotationsChartAnnotation[]-Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none.
referencesChartReference[]-Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`).
highlightsChartHighlight[]-A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary.
labelstring-The chart's accessible name and the start of its summary.
descriptionstring-One more sentence for the spoken summary.
xLabelstring-Name of the category column in the data table.
loadingboolean-Ghost bars pulse, the chart is aria-busy and not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it.
seedstring | number-Pins the hand.
accessibilityLayerboolean-Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point (drill down, filter).
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

ScatterChart

Points on two number lines, one marker shape per series; a `sizeKey` turns them into bubbles. Up to 600 points are drawn; the tooltip finds the nearest point.

PropTypeDefaultDescription
sizeKeystring-The data key that sizes each point.
dataRecord<string, unknown>[]-One row per category (per point for a scatter). Very long data is thinned (bars are averaged into at most 240 bins, fewer with several series so a chart never draws more than 480 bars; lines keep 1,500 points chosen to keep their shape) and the summary says so.
xKeystring-The category key (a scatter's x number). Default: the first key whose value is text.
seriesstring[]-Keys to draw, in stacking order. Default: the numeric keys named in the container's config, else the numeric keys of the data.
kindsRecord<string, "bar" | "line" | "area" | "scatter">-Mix marks: `{ revenue: "bar", target: "line" }`.
stackedbooleanfalseStack bars (or areas). Positive values stack up from zero, negative ones down.
curve"smooth" | "linear" | "step""smooth"How lines and areas join their points. Smooth is monotone: it never overshoots a peak.
yDomain[number | "auto", number | "auto"]-Pin the value axis. `auto` picks a tidy end (0, 50, 100...). Bars and areas always include zero unless `zero` is false.
zeroboolean-Whether the value axis includes zero. Default: yes for bars and areas, no for lines.
xFormatter(value: unknown, index: number) => string-Text of a category on the axis ("January" to "Jan"). The tooltip and the table keep the full value.
yFormatter(value: number) => string-Text of an axis tick. Default: compact numbers (1.2k, 3.4M).
valueFormatter(value: number) => string-Text of the numbers on bars, in the tooltip, the summary and the table. Default: 1,234.
dotsboolean | "auto""auto"Point markers on lines: drawn when there are few points and room for them. Each series has its own marker shape.
showValuesboolean | "auto""auto"Numbers on top of bars: drawn when they fit (wide enough, not stacked).
showGridbooleantrueBroken pencil rules across the plot.
showXAxis / showYAxisbooleantrueAxis labels (the baseline is always drawn).
annotationsChartAnnotation[]-Hand-circled call-outs: `{ at, series?, text, pen?, shape?, dx?, dy? }`. `at` is max, min, first, last, a category label or an index. `pen`: red, blue, ink, green. `shape`: loop, underline, none.
referencesChartReference[]-Dashed goal lines: `{ y, label?, pen? }` (a scatter also takes `{ x }`).
highlightsChartHighlight[]-A stretch of categories marked with a highlighter: `{ from, to, text? }` (labels or indices). It is part of the spoken summary.
labelstring-The chart's accessible name and the start of its summary.
descriptionstring-One more sentence for the spoken summary.
xLabelstring-Name of the category column in the data table.
loadingboolean-Ghost bars pulse, the chart is aria-busy and not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe the chart on once when it first appears. Reduced motion skips it; a redraw with new data never replays it.
seedstring | number-Pins the hand.
accessibilityLayerboolean-Accepted so shadcn's markup keeps working; the keyboard cursor, live region and data table are always on.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point (drill down, filter).
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

PieChart

Slices colored in with a marker, outlined in felt, each with its own pencil pattern and a percentage round the outside. Arrow keys walk the slices; the legend switches them off.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per slice.
nameKeystring-The key that names a slice and finds its config entry. Default: the first key with text.
valueKeystring-The key with the amount. Default: the first numeric key.
innerRadiusnumber0Fraction of the radius that is hole (0 to 0.9).
startAnglenumber0Degrees clockwise from twelve o'clock.
showLabelsbooleantruePercentages round the outside.
centerLabelReactNode | { value, label } | (info: { total, active }) => ReactNode-Text in the hole.
valueFormatter(value: number) => string-Number text.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

DonutChart

A PieChart with a hole (`innerRadius` 0.58) for a number in the middle.

PropTypeDefaultDescription
innerRadiusnumber0.58Fraction of the radius that is hole.
centerLabelReactNode | { value, label } | function-Text in the hole.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

RadarChart

A pencil web with a washed and shaded shape per series. The spokes are the keyboard stops.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per axis.
xKeystring-The key that names an axis.
seriesstring[]-Keys to draw.
maxnumber-The value at the rim. Default: a tidy number above the largest value.
levelsnumber4Rings of the web.
fillbooleantrueShade the shapes.
dotsbooleantrueA marker on each vertex.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

RadialChart

Concentric arcs in pale tracks: one ring per row, filled to its value. Ring names sit in the open quadrant.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per ring; a row's own `max` overrides `max`.
nameKey / valueKeystring-Which keys name and size a ring.
maxnumber100The value that fills a ring.
startAngle / endAnglenumber0 / 270Degrees clockwise from twelve o'clock.
centerLabelReactNode | { value, label }-Text in the hole.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

Gauge

A dial: marker zones (each with a pencil pattern) and a red felt needle, or a single colored arc. `role="meter"` with a value, a minimum, a maximum and a text, so assistive tech reads it. The children are the text under the pivot.

PropTypeDefaultDescription
valuenumber-The reading; clamped to min and max.
min / maxnumber0 / 100The ends of the dial.
zones{ to: number; tone?: 'good' | 'warn' | 'bad' | 'info' | 'brand' | number }[]-Colored stretches from the minimum up.
sweepnumber180Degrees the dial covers (180 is a half circle).
ticksnumber10Pencil ticks round the outside.
valueFormatter(value: number) => string-Number text.
labelstring-The accessible name.
childrenReactNode-Text under the pivot. Default: the value.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

Sparkline

One felt pull and a red dot at the end, a shaded area, or a row of marker bars, at 112 x 40 px unless you size it. A picture with a spoken summary; `interactive` makes it a chart with a cursor and a tooltip.

PropTypeDefaultDescription
data(number | null)[] | Record<string, unknown>[]-Numbers, or rows with `dataKey`.
dataKey / xKeystring-For rows: the value and the category key.
variant"line" | "area" | "bar""line"How it is drawn.
slot / seriesnumber / string-Palette slot, or the config key whose color to use.
endsbooleantrueA red dot on the last point.
extremesbooleanfalseSmall marks on the lowest and highest points.
interactivebooleanfalseHover and arrow keys show a tooltip.
labelstring-The accessible name.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

TallyChart

Counts as hand-tallied marks: four uprights and a slash across for every five, in the color of the row. When a row is too long for the width each mark stands for more, and the chart says so.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-One row per line of the board.
nameKey / valueKeystring-Which keys name and count a row.
unitnumberautoWhat one mark stands for.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

Heatmap

Squares colored in shades of one marker: a calendar (weeks across, weekdays down, month names on top) or a grid of your own rows and columns. Arrow keys move over the cells: left and right by week, up and down by day.

PropTypeDefaultDescription
dataRecord<string, unknown>[]-Calendar: rows with a date and a value. Grid: rows with a row name, a column name and a value.
variant"calendar" | "grid""calendar"The layout.
dateKey / valueKeystring"date" / "value"Calendar keys. Dates are `YYYY-MM-DD` or Date, read in UTC.
weeks / end / weekStartnumber / string | Date / 0 | 1-Weeks shown, the last day, and whether weeks start on Sunday (0) or Monday (1).
rowKey / colKey / rows / colsstring / string[]-Grid keys and the order of rows and columns.
levels / thresholdsnumber / number[]5Shades, and optionally the value at which each starts.
slot / seriesnumber / string-Palette slot, or the config key whose color to use. Default the green pencil.
unitstring-What a value counts ("pages"), shown in the tooltip.
showLegendbooleantrueThe Less / More key.
labelstring-The accessible name and the start of the spoken summary.
descriptionstring-One more sentence for the summary.
loadingboolean-Ghost drawing, aria-busy, not interactive.
emptyTextstring-Text shown when there is nothing to draw.
animatebooleantrueWipe on once when it first appears.
seedstring | number-Pins the hand.
onActiveChange(info: { index: number; series: number | null } | null) => void-The data point under the pointer or the keys changed.
onSelect(info: { index: number; series: number | null }) => void-A click, Enter or Space on a data point.
config / tooltip / legend / classNameChartConfig / boolean / boolean | 'top' | 'bottom' / string-Only when used on its own, without a ChartContainer: it wraps itself in one. Inside a container, className sizes the drawing.

Accessibility

  • Every chart is one tab stop with arrow-key navigation. The drawing is a `role="application"` with an accessible name, a role description ("bar chart") and a spoken summary; left and right move between data points (up and down between series, or between rows for sideways bars and grids), Home and End jump to the first and last, Escape closes the tooltip. The current point is announced through a polite live region.
  • Each chart ships its data as a visually hidden table (a caption, column and row headers) next to the drawing. Charts that are pictures (empty, loading, static sparklines) are `role="img"` with the same summary; a gauge is `role="meter"` with a value, a minimum, a maximum and a text.
  • Color is not the only channel: every series is named in the legend and the tooltip, values are announced, and lines have a marker shape and a dash pattern. Filled marks are solid color; set `patterns` to add hatching, dots, cross-hatching, rules and scribble, which also switch on by themselves in forced-colors mode. Legend entries are buttons with `aria-pressed`.
  • All chart text is DOM text in the hand fonts at 12 px or more (15 px script in the default density). Ink on paper is 14:1; muted tick labels 8.9:1. The pointer never has to be used: everything the tooltip shows is in the live region and the table.
  • Reduced motion removes the wipe-on, the pulse and the cursor slide. In Windows high contrast the drawing is replaced by the data table. Calm density draws hairlines, no fill offset and 12 px hand text for dense screens. The plot always runs left to right (a time axis does not mirror); the legend and the words on the tooltip follow the page direction.

Source

The files the CLI copies into your project.

Loading the source