Skip to Content
kindui

Area Chart

Show how a total changes over time, with filled areas you can stack.

Use an area chart to show how a measure changes across ordered categories, like months, when its size matters as much as its trend. Stack areas to show how parts add up to a total.

Hover the area, or focus the chart and press the arrow keys, to see each month's value.

Installation

npx shadcn@latest add @kind-ui/area-chart

Composition

AreaChart
├── AreaChart.Background
├── AreaChart.Grid
├── AreaChart.XAxis
├── AreaChart.YAxis
├── AreaChart.Series
├── AreaChart.Tooltip
├── AreaChart.Legend
└── AreaChart.Content

AreaChart holds the data, the series config and the accessible name, and draws only the parts you add. Add one AreaChart.Series per area. The tooltip and legend read their labels and colors from config. AreaChart.Content places your own HTML next to the legend.

Usage

Series

Each AreaChart.Series fills the dataKey it names, and takes its label and color from the matching config entry. Set type for the curve (linear by default, monotone for a smooth edge, stepAfter for steps) and fillOpacity to keep the grid visible through the fill.

A null value leaves a gap in the area. Pass connectNulls to the series to fill across it instead.

Stacking

Give series the same stackId to stack them, so the top edge shows the total:

Press Desktop or Mobile in the legend to highlight that area.

Stacks keep their layout when a series is hidden, so the other areas don't jump. To show each part as a share of the total, set stackOffset="expand" on the chart and format the axis and tooltip with createPercentStack; see Combo Chart.

Legend and Keyboard

Pressing a legend item highlights its area and dims the others, and screen readers hear "Highlighted Desktop." Press it again, or press Escape, to clear it. To hide and show areas from the legend instead, see Legend.

Focus the chart and press the arrow keys to move between months, which shows the tooltip, and Escape to dismiss it.

Points, Patterns and Materials

Areas have no points by default. Pass dot to show them, and pointStyle="border" or "colored-border" for outlined points; activePointStyle paints the point under the cursor. Set pattern to fill an area with hatching or dots instead of a flat color, which helps when colors alone are hard to tell apart:

<AreaChart.Series dataKey="mobile" stackId="visitors" pattern={{ kind: "hatch" }} />

Set material="clay" or "glow" on a series for a finish; see Materials.

Motion

Areas appear at once unless you set animate. Pass true to draw them in from left to right, or options to change the direction or the duration:

<AreaChart animate={{ revealDirection: "center-out", revealDurationMs: 800 }} {...props}>

revealDirection is left-to-right, right-to-left, center-out or edges-in. When the reader prefers reduced motion, areas appear without drawing in. See Motion.

Loading

Set loading while the data is on its way. The chart keeps its size and shows a placeholder area that sweeps across the plot, or holds still when the reader prefers reduced motion. Screen readers hear loadingLabel ("Loading chart" by default). The legend and tooltip come back when loading turns off:

<AreaChart loading={isPending} loadingLabel="Loading visitors" {...props}>

Background

Add AreaChart.Background for a decorative pattern behind the plot: pinpoints, crossings or waves. It adds nothing to the tooltip, legend or accessible name.

<AreaChart.Background pattern="waves" opacity={0.15} />

API Reference

AreaChart

Prop

Type

AreaChart.Series

Prop

Type

AreaChart and AreaChart.Series also take every prop of Recharts' AreaChart and Area, like margin, stackOffset, type, stackId and connectNulls.