Skip to content

shadcn.io is an independent project built on shadcn/ui

Live Line Chart Loading

A skeleton line while the stream connects, swapped for the live chart once data arrives. For React with TanStack Charts, in your shadcn/ui theme: the live chart, its code and a one-line install.

Charting library: TanStack Charts

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Usage

import { ChartLiveLineLoading } from "@/components/charts/chart-live-line-loading";
<ChartLiveLineLoading />

API Reference

LiveLineChart

PropType
dataLiveLinePoint[]

The streaming samples, oldest first. Append new points as they arrive.

valuenumber

The latest value. The chart eases its display toward it.

dataKey?string

Key used for the value field.

Default
"value"
window?number

Visible time window in seconds.

Default
30
numXTicks?number

Number of x axis labels; also sizes the leading offset.

Default
5
nowOffsetUnits?number

Leading offset in x tick units. 0 puts "now" at the right edge.

Default
0
exaggerate?boolean

Use a tight y range around the data instead of the default padded one.

Default
false
lerpSpeed?number

How fast the displayed value and y range ease toward their targets (0 to 1).

Default
0.08
margin?Partial<ChartMargin>

Space around the plot area in pixels. Missing sides use the default.

Type
Partial<ChartMargin>
Default
{ top: 24, right: 16, bottom: 32, left: 16 }
paused?boolean

Freeze the scrolling.

Default
false
childrenReactNode

The layers to draw: LiveLine, Grid (its horizontal rows; vertical columns are not drawn), LiveXAxis, LiveYAxis, ChartTooltip.

className?string

Extra CSS class name for the chart container.

style?CSSProperties

Inline styles for the chart container. Set height to size the chart.

ariaLabel?string

Accessible name of the chart.

Default
"Live line chart"
ariaDescription?string

Longer accessible description of the chart, exposed as aria-description.

LiveLine

PropType
dataKeystring

Key of the data field that holds the y values.

label?string

Series name in the default tooltip row, for example "Price". Defaults to the dataKey, as in bklit-ui.

stroke?string

Stroke color of the line.

Default
"var(--chart-line-primary)"
strokeWidth?number

Stroke width of the line in px.

Default
2
curve?CurveFactory

Accepted for bklit-ui compatibility and ignored: the line is always bklit's default curveMonotoneX. Native rolling refuses a custom curve path (custom-path, dist/motion-path.js:16), so the curve is sampled into rows (smoothRows in definition.ts) and another factory cannot be swapped in.

fill?boolean

Show the gradient fill under the line.

Default
true
pulse?boolean

Show the pulsing live dot at the right edge.

Default
true
dotSize?number

Radius of the live dot in px.

Default
4
badge?boolean

Show the value badge at the live tip.

Default
true
formatValue?(value: number) => string

Formats a value for the badge, the tooltip and the y axis labels. Defaults to two decimals.

Type
(value: number) => string
momentumColors?MomentumColors

Colors the line, fill and dot by momentum direction. Overrides stroke for the line.

ChartTooltip

PropType
showDatePill?boolean

Show the date pill that rides along the bottom of the plot.

Default
true
showCrosshair?boolean

Show the vertical crosshair line.

Default
true
showDots?boolean

Show a dot on every series at the hovered position.

Default
true
dotVariant?"dot" | "ring"

Dot style: a filled "dot" or a transparent "ring" square. Read by BarChart only.

Type
"dot" | "ring"
Default
"dot"
dotSize?number

Dot radius in px.

Default
5
dotRadiusFraction?number

Corner radius of the "ring" variant as a fraction of its side (0 is square, 0.5 is a circle). Read by BarChart only.

Default
0.25
dotScale?number

Multiplier applied to the dot or ring size. Read by BarChart and LiveLineChart.

Default
1
dotStrokeWidth?number

Stroke width of the dots in px.

Default
2
indicatorColor?string | ((point: Record<string, unknown>) => string)

Color of the crosshair. Only a string is applied; the function form that bklit-ui accepts is ignored and the default is used.

Type
string | ((point: Record<string, unknown>) => string)
Default
"var(--chart-crosshair)"
content?(props: { point: Record<string, unknown>; index: number }) => ReactNode

Replaces the default tooltip panel body. Receives the hovered data row and its index.

Type
(props: { point: Record<string, unknown>; index: number }) => ReactNode
rows?(point: Record<string, unknown>) => { readonly color: string; readonly label: string; readonly value: string | number }[]

Replaces the default rows (one per series) with your own list of { color, label, value }.

Type
(point: Record<string, unknown>) => { readonly color: string; readonly label: string; readonly value: string | number }[]
dotColor?string | ((point: Record<string, unknown>, line: ChartLineConfig) => string)

Fill of the tooltip dots. A function receives the hovered row and the series config, and is called again each time the hovered row changes. Defaults to each series' color; a ProfitLossLine's dot takes the color of the hovered value's sign.

Type
string | ((point: Record<string, unknown>, line: ChartLineConfig) => string)
children?ReactNode

Extra content rendered below the rows in the default panel, for example marker details. Without it, a chart with ChartMarkers lists the markers on the hovered date there.

className?string

Extra class name for the tooltip panel.

springConfig?SpringConfig

Spring for the floating panel when matchCrosshair is on. Defaults to the chart's tooltip spring.

matchCrosshair?boolean

Make the floating panel follow the pointer with the same spring as the crosshair instead of damping.

Default
false
damping?number

Spring damping for the floating panel when matchCrosshair is off. 0 moves the panel instantly.

Default
20
indicatorDasharray?string

Dash pattern of the crosshair. Omit for a solid line.

indicatorFadeEdges?IndicatorFadeEdges

Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts. The crosshair in this package is solid.

indicatorFadeLength?number

Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts.

boxSpringConfig?SpringConfig

Spring for the floating panel. Takes priority over matchCrosshair and damping.

panelStyle?CSSProperties

Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts. Style the panel with className or the --chart-tooltip-* CSS variables instead.

backgroundColor?string

Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts. Set --chart-tooltip-background instead.

indicatorWidth?IndicatorWidth

Thickness of the crosshair: a width in px, or "line" (1px), "thin" (2px), "medium" (4px) or "thick" (8px).

Default
"line"
columnWidth?number

Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts.

LiveXAxis

PropType
numTicks?number

Number of time labels. Defaults to the chart's numXTicks.

formatTime?(time: number) => string

Formats a time (in milliseconds since the epoch) into its label. Defaults to HH:MM:SS.

Type
(time: number) => string

LiveYAxis

PropType
minGap?number

Minimum gap in px between labels.

Default
36
position?"left" | "right"

Side of the plot the labels sit on.

Type
"left" | "right"
Default
"left"
formatValue?(value: number) => string

Formats a tick value into its label. Defaults to the LiveLine formatValue.

Type
(value: number) => string
allowDecimals?boolean

Allow fractional tick values.

Default
true

LineChartLoading

PropType
style?CSSProperties

Inline styles for the placeholder container. With aspectRatio: "unset" and a height the placeholder fills that height at any width, for example to hold a LiveLineChart's style.height while its stream connects.

margin?Partial<ChartMargin>

Space around the plot area in pixels. Missing sides use the default.

Type
Partial<ChartMargin>
Default
{ top: 40, right: 40, bottom: 40, left: 40 }
stroke?string

Color of the traveling loading segment.

Default
"var(--bkm-foreground)"
strokeOpacity?number

Opacity of the traveling loading segment.

Default
0.5
gridStroke?string

Color of the grid lines while loading. Use color-mix or an oklch alpha to set the opacity.

Default
"color-mix(in oklch, var(--chart-grid) 50%, transparent)"
gridShimmerStroke?string

Color of the shimmer band that travels across the grid. Use color-mix or an oklch alpha to set the opacity.

Default
"color-mix(in oklch, var(--bkm-foreground) 68%, transparent)"
gridShimmer?boolean

Animate a shimmer band across the grid lines. Always off when loadingStyle is "sweep".

Default
true
gridShimmerLength?number

Accepted for bklit-ui compatibility. It has no effect: the shimmer band has a fixed width.

gridShimmerSpeed?number

Shimmer speed multiplier; higher is faster.

Default
1
gridShimmerSync?boolean

Accepted for bklit-ui compatibility. It has no effect: the shimmer always loops on the same period as the line pulse.

loadingStyle?LoadingStyle

Loading animation: "pulse" sends a bright segment along the line, "sweep" sweeps a soft diagonal shimmer across it.

Default
"pulse"
label?string

Text shown centered over the placeholder, with a shimmer. An empty string hides it.

Default
"Loading"
aspectRatio?string

CSS aspect ratio of the placeholder, as "width / height".

Default
"2 / 1"
className?string

Extra CSS class name for the placeholder container.

Default
""