Reference Area

Shaded Y band for target ranges and thresholds on cartesian charts — solid or pattern fill, dashed edges, and Y-axis tick coloring

Preview

Installation

pnpm dlx shadcn@latest add @bklit/reference-area

Usage

ReferenceArea draws a horizontal band between two Y data values. Place it as a child of any cartesian chart (LineChart, AreaChart, BarChart, ScatterChart, CandlestickChart, ComposedChart, LiveLineChart). It renders in the underlay layer — above grid and background, behind series.

import { LineChart, Line, Grid, ReferenceArea, ChartTooltip, XAxis } from "@bklitui/ui/charts";

<LineChart data={data}>
  <Grid horizontal />
  <ReferenceArea y1={160} y2={220} strokeStyle="dashed" showMarkers />
  <Line dataKey="value" />
  <XAxis />
  <ChartTooltip />
</LineChart>

Omit y1 or y2 to extend the band to the top or bottom of the plot. Use axisLabelColor to tint Y-axis tick labels whose values fall inside the band.

Props

PropTypeDefaultDescription
y1numberLower Y data bound (extends to plot top when omitted)
y2numberUpper Y data bound (extends to plot bottom when omitted)
x1Date | numberStarting X data coordinate (extends to plot left when omitted)
x2Date | numberEnding X data coordinate (extends to plot right when omitted)
yAxisIdstring | number"left"Y-scale group id
fillstringmuted mix on --chart-foreground-mutedSolid fill when pattern is "none"
fillOpacitynumber1Fill opacity
patternPattern preset id"none"Pattern fill inside the band
patternColorstringPattern stroke or tile color
patternScalenumberPattern tile scale
patternStrokeWidthnumberLine stroke width for line-based patterns
patternRadiusnumberDot or circle radius for dots / circles
patternComplementbooleanAlternate tile fill for circle patterns
patternFillstringSolid fill inside circles
patternDotFillbooleanDot grid only — hollow dots when false
patternTileBackgroundstringBackground color inside each pattern tile
strokestringEdge line color
strokeWidthnumber1Edge line width
strokeStyle"solid" | "dashed""solid"Edge line style
strokeDasharraystring"4,4"Dash array when strokeStyle is "dashed"
fadeEdgesbooleantrueFade fill and edges at left/right
fadeEdgesLengthnumber10Horizontal fade zone as % of plot width per edge (0–45)
axisLabelColorstringY-axis tick label color for values inside the band
showMarkersbooleanfalseInward bracket markers at the horizontal center
markerColorstringBracket marker color
markerSizenumberBracket marker size
ifOverflow"hidden" | "visible""hidden"Clip band to the plot when bounds exceed the domain

Pattern presets match Background (diagonal, dots, cross, …).

Studio

Edit in Studio

Open in Studio

Open Studio with the line chart and select Reference Area in the layers panel to tune bounds, fill, pattern, edges, and markers. The same layer is available on area, bar, candlestick, composed, live line, line, and scatter charts.

Examples

Dashed band with markers

<LineChart data={data}>  <Grid horizontal />  <ReferenceArea y1={160} y2={220} strokeStyle="dashed" showMarkers />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></LineChart>

Pattern fill with axis labels

<LineChart data={data}><Grid horizontal /><ReferenceArea  y1={160}  y2={200}  pattern="diagonal"  patternColor="oklch(0.76 0.144 180.392 / 0.17)"  patternScale={0.75}  patternStrokeWidth={1.5}  stroke="oklch(0.841 0.142 159.667 / 0.49)"  axisLabelColor="oklch(0.795 0.152 164.722)"/><Line dataKey="value" /><XAxis /><ChartTooltip /></LineChart>

Colored markers

<LineChart data={data}><Grid horizontal /><ReferenceArea  y1={160}  y2={220}  stroke="var(--chart-1)"  strokeStyle="dashed"  showMarkers  markerColor="var(--chart-1)"/><Line dataKey="value" /><XAxis /><ChartTooltip /></LineChart>

See Reference Band examples on each cartesian chart gallery: line, area, bar, composed, scatter, candlestick, live line, and profit/loss line.