Line Chart

Line and area charts that morph with your data, with a snapping crosshair and value tooltips.

Preview

Monthly revenue

Demo data, in thousands of dollars

Illustrative monthly revenue data
CategoryThis yearLast yearTarget
Jan$36.4K$36.5K$36.0K
Feb$43.0K$35.8K$38.5K
Mar$43.9K$36.3K$41.0K
Apr$44.2K$39.9K$43.5K
May$49.1K$43.3K$46.0K
Jun$52.2K$40.9K$48.5K
Jul$53.6K$44.2K$51.0K
Aug$58.7K$45.6K$53.5K
Sep$63.8K$51.1K$56.0K
Oct$67.1K$55.5K$58.5K
Nov$71.6K$53.7K$61.0K
Dec$75.6K$55.5K$63.5K

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/line-chart

API Reference

LineChart

series
readonly XYSeries[]
—
categories
readonly string[]

Unique x-axis labels in display order. Values align with them by index.

—
variant?
"area" | "line"

`area` fills each line down to zero with a fading gradient.

—
curve?
"step" | "monotone" | "linear"
—
domain?
readonly [number, number]

Fixed value-axis bounds. Defaults to rounded bounds around the visible series.

—
activeId?
string | null

Inspected category, by label.

—
defaultActiveId?
string | null
—
onActiveChange?
((id: string | null) => void)
—
hiddenSeries?
readonly string[]

Series ids hidden through the legend.

—
defaultHiddenSeries?
readonly string[]
—
onHiddenSeriesChange?
((ids: readonly string[]) => void)
—
formatValue?
((value: number) => string)
—
formatTick?
((value: number) => string)

Axis tick labels. Defaults to compact notation (1.2K).

—
label?
string
—
status?
"ready" | "loading"

`loading` hides the lines behind a pulsing placeholder until your data arrives; switching to `ready` hands off to the draw-in. Keep one chart mounted across both states.

—
loadingLabel?
string

Shown over the placeholder while loading. An empty string hides it.

—
className?
string
—

LineChartLegend

className?
string
—

LineChartPlot

height?
number

Plot height in px, excluding the category labels.

288
strokeWidth?
number

Stroke width of each line, in px.

2
showGrid?
boolean
true
fadeEdges?
boolean

Fade lines and fills out toward the left and right edges of the plot.

true
className?
string
—

LineChartTooltip

className?
string
—
side?
"auto" | "left" | "right"

`auto` sits right of the point, flips left near the right edge, and on plots too narrow for either moves above or below the point instead.

auto

Updated