React Area Chart
An animated React area chart with soft gradient fills, a crosshair tooltip and keyboard reading. Each row of readonly ChartRow[] is one x value; every series key holds a number, and its fill runs down to the zero baseline.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/line-chart.jsonVisits per month
Area chart with a gradient fill
The fill fades to transparent. Drag across the chart or use the arrow keys to read a month.
Visits per month
Sessions across the site
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
import { ChartTable } from "@/components/sheenui/charts/chart-parts/empty-table";
import { type ChartSeries } from "@/components/sheenui/charts/chart-utils";
import { AreaChart } from "@/components/sheenui/charts/line-chart";
// Package build (after the first npm release, or a packed tarball): import { AreaChart, ChartCard, ChartTable, type ChartSeries } from "@sheenui/theme";
const data = [
{ month: "Jun", visits: 9400 },
{ month: "Jul", visits: 10100 },
{ month: "Aug", visits: 11300 },
{ month: "Sep", visits: 11900 },
{ month: "Oct", visits: 12800 },
];
const series: ChartSeries[] = [{ key: "visits", label: "Visits", color: 1 }];
export function Example() {
return (
<ChartCard title="Visits per month" table={<ChartTable data={data} index="month" series={series} />}>
<AreaChart data={data} index="month" series={series} aria-label="Visits per month" />
</ChartCard>
);
}Files to copy
11 folders · 28 files · 4 packages
- From
theme/src/ components/charts/{line-chart.tsx, chart-annotations.tsx, chart-brush.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-sync.tsx, chart-utils.ts}components/charts/chart-parts/components/drawer/parts/sheet.tsxcomponents/kbd/components/menu/components/skeleton/components/status-icons/hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/line-chart.jsonRegistry item: line-chart. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".
AreaChart props
LineChartLabels keys and English defaults (3)
When to use an area chart
A React area chart suits totals that accumulate or fill a range, such as traffic, storage used or active users. The gradient adds weight to the line without hiding the grid, which makes one or two series look calm and readable on a glass card.
When you need several series, the stacked area chart and the range area chart keep them readable. For plain trends compare the React line chart, and for tiny inline trends use a sparkline.
How the fill behaves
The fill is drawn once per series from the line down to the baseline and fades with the gradient, so a lone series reads as a soft silhouette of its own total. Two overlapping series show through each other where the lower one is the smaller, but the upper fill hides the lower line where it is the larger, so keep to one or two series and let the legend toggle the rest off.
The line on top of the fill keeps the same crosshair and point markers as the line chart, so reading a month never depends on the shading. Because the fill grows from the baseline, a truncated value axis makes a small change look like a large block of colour: leave zero on unless the title says the axis is cut.
Frequently asked questions
Keyboard
Accessibility
- Tab focuses the chart as one stop; the arrow keys read each point and announce every series value at it.
- The Chart / Table tabs give the same numbers as a LineTable, so no value depends on the gradient fill, which is decoration.
- The brush under a long series is its own tab stop: arrows, Page Up and Page Down, Home and End move the range.
- Reduced motion: the fill and line appear at once and data changes jump.
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .