Line Chart

Charts

Shows trends over a continuous axis.

Line charts emphasize direction and rate of change. Use one for time-series data where the shape of the trend matters more than individual values.

npx shadcn@latest add line-chart

Default

A smooth line with dots and a shared tooltip.

Preview
Live
tsx
1<LineChart data={conversionsByDay} xKey="day" yKey="conversions" height={220} />

Custom

A filled, dotless line in an accent color.

Preview
Live
tsx
1<LineChart
2 data={activeUsersByHour}
3 xKey="hour"
4 yKey="users"
5 color="var(--color-chart-3)"
6 height={220}
7 withDots={false}
8 fillArea
9/>

API reference

All props of the underlying Base UI primitive are forwarded. The table below documents the Shelf-specific props.

PropTypeDescription
dataRecord<string, unknown>[]The data rows to plot.
xKeystringThe key used for the horizontal axis.
yKeystringThe key used for the line values.
colorstring= "var(--color-primary)"The line stroke color.
heightnumber= 240The chart height in pixels.
strokeWidthnumber= 2The line thickness.
withDotsboolean= trueWhether to render points at each value.
fillAreaboolean= falseFills the area under the line with a soft gradient.