Line Chart
line-chartOne or more series over an ordered axis on TanStack Charts, as smooth lines or as areas that fade to their baseline. A dashed cursor snaps to the nearest x from anywhere in the plot, the tooltip lists every series there, and areas can stack.
import { LineChart } from "@/components/forme/line-chart/line-chart";
// Weekly active users by platform over a quarter.
const usage = [
{ week: "Jul 7", desktop: 4120, mobile: 2380 },
{ week: "Jul 14", desktop: 4390, mobile: 2610 },
{ week: "Jul 21", desktop: 4250, mobile: 2940 },
{ week: "Jul 28", desktop: 4710, mobile: 3120 },
{ week: "Aug 4", desktop: 4980, mobile: 3060 },
{ week: "Aug 11", desktop: 4820, mobile: 3480 },
{ week: "Aug 18", desktop: 5310, mobile: 3710 },
{ week: "Aug 25", desktop: 5620, mobile: 3950 },
{ week: "Sep 1", desktop: 5480, mobile: 4290 },
{ week: "Sep 8", desktop: 5960, mobile: 4410 },
];
const compact = (value: number) =>
value >= 1000 ? `${(value / 1000).toFixed(value % 1000 === 0 ? 0 : 1)}k` : String(value);
export function LineChartDemo() {
return (
<div className="w-full rounded-xl border border-border bg-card p-5 lit edge">
<p className="text-caption-1-medium text-muted-foreground">Weekly active users</p>
<p className="mt-1 text-[1.75rem] leading-none font-semibold tracking-[-0.03em] tabular-nums">
10,370
</p>
<LineChart
className="mt-5"
label="Weekly active users on desktop and mobile, July to September"
data={usage}
index="week"
variant="area"
formatValue={compact}
series={[
{ key: "desktop", label: "Desktop" },
{ key: "mobile", label: "Mobile" },
]}
/>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
LineChart
One or more series over an ordered axis, as lines or as areas that fade to their baseline.
| Prop | Type | Default | Description |
|---|---|---|---|
data* | readonly Row[] | — | |
index* | keyof Row & string | — | The field along the x axis: a month, a date, a release. |
series* | readonly LineChartSeries<Row>[] | — | Up to eight. Colours are assigned from --chart-1 onward, in this order. |
label* | string | — | Accessible name. Say what is measured and over what period. |
variant | "line" | "area" | "line" | area fills each line down to zero with a fading gradient. |
stacked | boolean | false | stacked piles the areas so the top edge is the total. Area variant only. |
curve | "monotone" | "linear" | "step" | "monotone" | |
dots | boolean | false | A dot on every point, not only the focused one. |
formatValue | (value: number) => string | plain | |
height | number | 260 | |
className | string | — |
Related


Area Chart
A line or area chart in plain SVG with no chart library. A crosshair snaps to the nearest point and lists every series, arrow keys walk it, round tick values, a legend from two series up, and a hidden table so screen readers get the numbers.
data display

Chart
The tooltip and legend every Forme chart shares: a floating panel with a colour, a name and a right-aligned value per series, and a row of swatches. Installed with any chart; use them directly to give a chart of your own the same finish.
data display

Composed Chart
Columns and a line on one axis, on TanStack Charts: volume against its target, actuals against the plan. Rounded columns side by side, the line drawn over them, and a band cursor that lists every series in the column.
data display