shadcn.io is an independent project built on shadcn/ui
Installation
Usage
import { ChartAreaReferenceBand } from "@/components/charts/chart-area-reference-band";<ChartAreaReferenceBand />API Reference
AreaChart
dataChartDatum[]
The rows to plot. Each row is an object holding the x value under xDataKey and one number per series under that series' dataKey.
xDataKey?string
Key of the x value in each row. The value must be a Date (or something new Date() accepts, such as a timestamp).
- Default
"date"
status?ChartStatus
"loading" shows the loading state (skeleton area, grid shimmer, optional label) and ignores the pointer; switching to "ready" reveals the real data on the same chart instance.
- Default
"ready"
animationDuration?number
Duration of the entrance reveal in milliseconds. 0 skips the animation.
- Default
1100
margin?Partial<ChartMargin>
Space around the plot area in pixels, for axis labels and the tooltip. Missing sides use the default.
- Type
Partial<ChartMargin>- Default
{ top: 40, right: 40, bottom: 40, left: 40 }
aspectRatio?string
CSS aspect ratio of the chart ("width / height" or a number), applied to the container width.
- Default
"2 / 1"
className?string
Extra CSS class name for the chart container.
onPhaseChange?(phase: ChartPhase) => void
Called with "loading" or "ready" when status changes (and once on mount).
- Type
(phase: ChartPhase) => void
childrenReactNode
The layers to draw: Grid, Area, XAxis, YAxis, ChartTooltip and the other chart children.
loadingLabel?string
Text shown centered over the chart, with a shimmer, while status is "loading". Nothing is shown when it is unset or empty.
style?CSSProperties
Inline styles for the chart container, for example a fixed height for a brush strip.
animationEasing?string
Accepted for bklit-ui compatibility. It has no effect: the entrance always uses the default reveal easing.
yDomainTween?boolean
Animate the y domain when the data or status changes instead of jumping to the new scale.
- Default
true
yDomainTweenDuration?number
Accepted for bklit-ui compatibility. It has no effect: the y-domain tween always lasts 500 ms.
xDomain?[Date, Date]
Visible x range as [start, end], used for brush zoom. The chart plots only this range of data.
xDomainSlotCount?number
Length of the full dataset while xDomain zooms into part of it. It keeps the x spacing consistent with the unzoomed chart.
tweenYDomainOnXDomainChange?boolean
Accepted for bklit-ui compatibility. It has no effect.
enterTransition?EnterTransition
Accepted for bklit-ui compatibility. It has no effect: set the entrance length with animationDuration.
revealSignature?string
Changing this string replays the entrance animation. Do not change it when only the data changes.
ariaLabel?string
Accessible name of the chart.
- Default
"Area chart"
ariaDescription?string
Longer accessible description of the chart, exposed as aria-description.
Grid
horizontal?boolean
Show horizontal grid lines.
- Default
true
vertical?boolean
Show vertical grid lines.
- Default
false
numTicksRows?number
Number of horizontal grid lines. Ignored when rowTickValues is set.
- Default
5
numTicksColumns?number
Number of vertical grid lines.
- Default
10
rowTickValues?number[]
Explicit y values for the horizontal grid lines. Overrides numTicksRows.
stroke?string
Color of the grid lines.
- Default
"var(--chart-grid)"
loadingStroke?string
Grid color while the chart is loading. Falls back to stroke.
strokeOpacity?number
Opacity of the grid lines.
- Default
1
strokeWidth?number
Width of the grid lines in px.
- Default
1
strokeDasharray?string
Dash pattern of the grid lines.
- Default
"4,4"
highlightRowValues?number[]
Y values of horizontal lines drawn with the highlight styling, for example a zero baseline.
highlightRowStroke?string
Color of the highlighted rows.
- Default
"var(--chart-foreground-muted)"
highlightRowStrokeOpacity?number
Opacity of the highlighted rows.
- Default
1
highlightRowStrokeWidth?number
Width of the highlighted rows in px.
- Default
1
highlightRowStrokeDasharray?string
Dash pattern of the highlighted rows.
- Default
"0"
fadeHorizontal?boolean
Fade the horizontal lines toward transparent at the left and right edges.
- Default
true
fadeVertical?boolean
Fade the vertical lines toward transparent at the top and bottom edges.
- Default
false
hideHorizontalEdgeLines?boolean
Drop the first and last horizontal line (kept when two or fewer remain).
- Default
false
hideVerticalEdgeLines?boolean
Drop the first and last vertical line (kept when two or fewer remain).
- Default
false
yAxisId?string | number
Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts. The grid follows the primary (left) y scale.
- Type
string | number
shimmer?boolean
While the chart is loading, sweep a bright band across the grid.
- Default
false
shimmerStroke?string
Color of the shimmer band.
- Default
"color-mix(in oklch, var(--bkm-foreground) 68%, transparent)"
shimmerLength?number
Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts.
shimmerSpeed?number
Speed multiplier of the shimmer sweep. 2 is twice as fast.
- Default
1
shimmerSync?boolean
Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts.
ReferenceArea
y1?number
Lower y data bound. The band extends to the plot top when omitted.
y2?number
Upper y data bound. The band extends to the plot bottom when omitted.
x1?Readonly<Date> | number
Starting x data coordinate. The band extends to the plot left when omitted.
- Type
Readonly<Date> | number
x2?Readonly<Date> | number
Ending x data coordinate. The band extends to the plot right when omitted.
- Type
Readonly<Date> | number
yAxisId?string | number
Id of the y-scale group the y bounds refer to.
- Type
string | number- Default
"left"
fill?string
Fill color of the band.
- Default
`color-mix(in oklch, var(--chart-foreground-muted) 12%, transparent)`
fillOpacity?number
Opacity of the fill.
- Default
1
pattern?PatternPresetId
Pattern that fills the band instead of the solid fill: "diagonal", "horizontal", "vertical", "cross", "dots", "circles", and the other presets.
- Default
"none"
patternColor?string
Color of the pattern lines or dots.
- Default
"var(--chart-foreground-muted)"
patternScale?number
Scales the pattern tile. 2 doubles it.
- Default
1
patternStrokeWidth?number
Stroke width of the pattern lines, or of the ring around circles.
patternRadius?number
Radius of the pattern dots or circles in px.
patternComplement?boolean
Also draw circles at the tile corners so the pattern reads as a staggered grid.
patternFill?string
Fill color of the pattern dots or circles.
patternDotFill?boolean
Fill the pattern dots (false draws rings).
patternTileBackground?string
Background color painted under each pattern tile.
stroke?string
Color of the band's top and bottom edge lines.
- Default
"var(--chart-foreground-muted)"
strokeWidth?number
Edge line width in px.
- Default
1
strokeStyle?ReferenceAreaStrokeStyle
"dashed" or "solid" edge lines.
- Default
"dashed"
strokeDasharray?string
Dash pattern of the edge lines when strokeStyle is "dashed".
- Default
"4,4"
fadeEdges?boolean
Fade the fill and edge lines out over the outer 10% of the band at the left and right.
- Default
true
fadeEdgesLength?number
Accepted so bklit-ui code compiles. Not applied by this package. The fade zone is fixed at 10%.
axisLabelColor?string
Accepted so bklit-ui code compiles. Not applied by this package.
showMarkers?boolean
Draw inward triangle markers at the horizontal center of the band's top and bottom edges.
- Default
false
markerColor?string
Color of the center markers.
- Default
"var(--chart-1)"
markerSize?number
Size of the center markers in px.
- Default
6
ifOverflow?ReferenceAreaIfOverflow
Accepted so bklit-ui code compiles. Not applied by this package. The band is always clipped to the plot.
className?string
Accepted so bklit-ui code compiles. Not applied by this package.
Area
dataKeystring
Key of the data field that holds this area's y values.
label?string
Name of the series in the default tooltip row and the chart context's \lines\ (what a legend built from them reads). Defaults to \dataKey\.
stroke?string
Color of the area's top line. Falls back to fill, then to the default line color.
- Default
"var(--chart-line-primary)"
strokeWidth?number
Stroke width of the top line in px.
- Default
2
fill?string
Fill color of the area. Defaults to the resolved stroke.
fillOpacity?number
Opacity of the fill at the top of the area, before the gradient fades it toward gradientToOpacity.
- Default
0.4
curve?CurveFactory
d3-shape curve factory used to interpolate between points.
- Default
curveMonotoneX
yAxisId?string | number
Id of the y scale this area is plotted against.
- Type
string | number- Default
"left"
showLine?boolean
Draw the stroke line along the top of the area.
- Default
true
gradientToOpacity?number
Fill opacity at the bottom of the vertical gradient.
- Default
0
gradientSpan?number
Accepted for bklit-ui compatibility. It has no effect in bklit-tanstack-charts.
fadeEdges?FadeEdges
Fade the area toward transparent at the chart edges. true fades both ends, "left" or "right" fades one side.
- Default
false
showMarkers?boolean
Draw a circle marker at every data point.
- Default
false
markers?Readonly<SeriesPointMarkerStyle>
Styling of the point markers drawn by showMarkers. See SeriesPointMarkerStyle.
- Type
Readonly<SeriesPointMarkerStyle>
showHighlight?boolean
Draw a highlighted segment of the top line around the hovered point.
- Default
true
dashFromIndex?number
Data index from which the top line is drawn dashed (inclusive).
dashArray?string
Dash pattern of the dashed tail when dashFromIndex is set.
- Default
"6,4"
animate?boolean
Whether the point markers animate in. The area itself always enters with the chart's animationDuration.
- Default
true
loading?boolean
Show the loading pulse overlay on this area. When unset, the pulse follows the chart's status. Set false to disable it.
loadingStroke?string
Stroke color of the loading pulse overlay.
- Default
"var(--chart-foreground)"
loadingStrokeOpacity?number
Stroke opacity of the loading pulse overlay.
- Default
0.5
loadingPulseMode?LineLoadingPulseMode
Phase of the loading pulse: "loop" repeats, "exit" plays the loading to ready transition, "enter" plays ready to loading.
- Default
"loop"
loadingStyle?LoadingStyle
Loading animation: a travelling "pulse" or a diagonal "sweep" shimmer.
- Default
"pulse"
XAxis
numTicks?number
Target number of tick labels along the x axis.
- Default
5
tickerHalfWidth?number
Half-width in px of the zone around the date pill inside which tick labels are hidden. Line, area and composed charts widen it to the pill's half-width plus the widest tick label's, so no label sits half under the pill.
- Default
50
tickMode?"domain" | "data"
Where ticks fall: "data" places them on evenly spaced data rows, "domain" places them at evenly spaced time values across the x domain.
- Type
"domain" | "data"- Default
"data"
formatValue?(value: Readonly<Date>) => string
Formats a tick date into its label. Defaults to a short month and day such as "Jan 5".
- Type
(value: Readonly<Date>) => string
YAxis
yAxisId?string | number
Id of the y scale this axis labels. Must match the yAxisId of the series that use it.
- Type
string | number- Default
"left"
orientation?"left" | "right"
Side of the plot the axis sits on. The primary axis is on the left; additional axes default to the right.
- Type
"left" | "right"- Default
"left"
numTicks?number
Target number of tick labels. The primary axis also sets the number of horizontal grid lines.
- Default
5
formatLargeNumbers?boolean
Abbreviate values of 1000 and above as thousands, with one decimal where needed, for example 2k or 1.5k.
- Default
true
formatValue?(value: number) => string
Formats a tick value into its label. Overrides formatLargeNumbers.
- Type
(value: number) => string
ChartTooltip
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.