Gauge

Notch, solid or sector dial (or a linear notch track) with rulers, needles, zones, progress rings, dots, glow, a center label and a zero-bounce sweep animation

Installation

pnpm dlx shadcn@latest add @bklit/gauge-chart

Usage

Gauge draws notches around an arc (default) or along a horizontal track (orientation="linear"). The center label is optional — omit centerValue for a track-only gauge.

  • Fill vs center: value is the fill level 0–100. centerValue is the statistic shown in the label (often the same story or a related KPI).
  • Arc center: arc gauges overlay the label in the middle of the sweep (PieCenter-style NumberFlow + caption).
  • Linear label placement: with orientation="linear", place the label above or below the track using labelPlacement (top | bottom) and labelAlign (start | center | end) — the same six-position model as chart legend (top/bottom × left/center/right).
  • Responsive: omit width and height to fill the parent. Arc gauges use minWidth (default 300) and an aspect ratio. Linear gauges fill the parent width and use linearHeight (default 24).
  • Linear notches: linear gauges default to uniformWidth (rectangular notches). Pass uniformWidth={false} for tapered ticks.
  • Patterns / gradients in <defs>: pass PatternPreset, LinearGradient, etc. as children, then set activeFill / inactiveFill to url(#id).
  • Arc gradients: set useGradient. Optional activeGradient and inactiveGradient are [hexFrom, hexTo] tuples (interpolated along the notch index).
  • Fill opacity: activeFillOpacity and inactiveFillOpacity map to SVG fill-opacity (0–1). Defaults are 1 for active notches and 0.8 for the track; docs and gallery examples use inactiveFillOpacity={0.4} for a lighter track.
  • Corner radius: notchCornerRadius is the fillet in pixels at each notch corner (0 = sharp). Large values are clamped by edge length and radial depth so shapes can approach a capsule / near-circular look.
  • Dials (arc only): swap the notch track for a solid stroke or none (arcStyle), then layer a ruler, needle, zones, sector, progressRing, dots, glow and centerDisc — see Dial features.
  • Animation: the fill sweeps from zero on a zero-bounce spring and follows later value changes from where it is; reduced motion renders instantly — see Animation.
import { Gauge } from "@bklitui/ui/charts";

export default function RevenueGauge() {
  return (
    <Gauge
      value={66}
      centerValue={428_000}
      spacing={25}
      inactiveFillOpacity={0.4}
      defaultLabel="ARR run rate"
      formatOptions={{
        style: "currency",
        currency: "USD",
        maximumFractionDigits: 0,
      }}
    />
  );
}

Linear gauge

Track-only (no label):

<Gauge
  orientation="linear"
  value={72}
  totalNotches={72}
  spacing={0}
  notchCornerRadius={3}
  inactiveFillOpacity={0.4}
  useGradient
/>

With label below center:

<Gauge
  orientation="linear"
  value={72}
  centerValue={428_000}
  defaultLabel="ARR run rate"
  labelPlacement="bottom"
  labelAlign="center"
  totalNotches={72}
  spacing={0}
  notchCornerRadius={3}
  inactiveFillOpacity={0.4}
  useGradient
/>

Dial features

Everything below is arc only — orientation="linear" ignores these props. Layers compose freely: rings, zone bands and an outside ruler claim space from the outside in and the track shrinks to make room, so you can stack them without tuning radii by hand.

Animation

On mount the track (and ruler) fades in, then the fill sweeps from 0 to value on a zero-bounce spring — notches light up in order as the sweep passes them, ruler ticks brighten, and the needle, sector, ring and dots all ride the same motion value. When value changes the sweep continues from wherever it is (keeping its velocity), rather than restarting from zero. With prefers-reduced-motion the gauge renders at its value instantly.

  • enterTransition — any motion Transition for the sweep. Default { type: "spring", visualDuration: 0.9, bounce: 0 }.
  • enterStaggerScale — scales the short delay before the sweep starts (clamped 0.25–2.5).
  • Replay — change the gauge's key to remount it and play the enter again.
const [value, setValue] = useState(38);const [replay, setReplay] = useState(0);<Gauge  key={replay} // remount to replay the enter  value={value}  centerValue={value}  defaultLabel="Cluster load"  suffix="%"  needle="line"  ruler  totalNotches={72}  spacing={40}  notchLengthPercent={34}  notchCornerRadius={2}  startAngle={148}  endAngle={392}// enterTransition={{ type: "spring", visualDuration: 1.4, bounce: 0 }}// enterStaggerScale={2}/><Button onClick={() => setValue(randomValue())}>Change value</Button>  <Button onClick={() => setReplay((n) => n + 1)}>Replay enter</Button>

Arc styles

arcStyle picks how the track is drawn: discrete notches (default), one rounded solid stroke (thickness via arcThickness, a fraction of the gauge size — default 0.035), or none to drop the track entirely and let a sector, progress ring or dots carry the value.

arcStyle="notches"
arcStyle="solid"
arcStyle="none" + progressRing
<Gauge value={64} centerValue={64} suffix="%" inactiveFillOpacity={0.4} /><Gauge arcStyle="solid" arcThickness={0.05} inactiveFillOpacity={0.6} value={64} centerValue={64} suffix="%" /><Gauge arcStyle="none" progressRing value={64} centerValue={64} suffix="%" />

With arcStyle="solid", activeFill / inactiveFill colour the fill and track, and useGradient paints a left → right ramp (activeGradient or --chart-1 → --chart-5).

Ruler

ruler adds a scale. true draws 50 intervals with a major tick every 5 inside the track; ticks brighten as the fill passes them (highlightActive). Pass an object to move it outside, change tick counts, lengths, gap and colour, or add labels — true / "majors" labels every major tick, "ends" only the first and last, and an object sets the label domain (min / max, default 0 → 100), a format function and a color.

ruler
position: "outside", labels: "ends"
labels: { min: 0, max: 8, format }
<Gauge ruler value={53} {...dialProps} /><GaugearcStyle="solid"ruler={{ position: "outside", ticks: 20, majorEvery: 5, labels: "ends" }}value={53}/><GaugearcStyle="solid"arcThickness={0.02}centerValue={4.2}defaultLabel="rpm × 1000"ruler={{  position: "outside",  ticks: 16,  majorEvery: 4,  labels: { min: 0, max: 8, format: (v) => `${v}k` },}}value={(4.2 / 8) * 100}/>

value is always 0–100. When your reading has real units, map it (value={(reading / max) * 100}) and give the ruler labels the real domain.

Needles

needle adds a pointer that sweeps with the fill. true is the gradient needle; pass a variant name for the others, or an object for full control: color, width (stroke width for line / gradient, base width for triangle / polygon), length (fraction of the reach — default 0.55 floats the needle clear of the center label; 1 runs from the pivot), and pivot to draw a cap at the center.

needle="line"
needle="gradient"
needle="triangle"
needle="polygon"
<Gauge needle="line" ruler value={62} {...dialProps} /><Gauge needle ruler value={62} {...dialProps} /> {/* "gradient" */}<Gauge needle="triangle" ruler value={62} {...dialProps} /><Gauge needle="polygon" ruler value={62} {...dialProps} /><Gauge needle={{ variant: "line", length: 1, pivot: true, color: "var(--chart-1)" }} value={62} />

tip sets where the needle ends: just inside the track (inner, default), at the track's outer edge (outer), or past the outermost layer — ring, zone band or outside ruler (edge).

tip: "inner"
tip: "outer"
tip: "edge"
<Gauge  arcStyle="solid"  ruler={{ position: "outside", ticks: 20, majorEvery: 5 }}  needle={{ variant: "triangle", tip: "edge", length: 0.3, width: 8 }} // "inner" | "outer" | "edge"  value={62}  />

Zones

zones marks coloured ranges on the 0–100 scale ({ from, to, color }[], later zones win where they overlap). zoneDisplay chooses how they render: band (default) — a thin arc ringing the track; fill — the lit notches or solid fill take the zone colour where they overlap it; both.

zoneDisplay="band"
zoneDisplay="fill"
zoneDisplay="both"
const zones = [  { from: 0, to: 60, color: "#22c55e" },  { from: 60, to: 85, color: "#f59e0b" },  { from: 85, to: 100, color: "#ef4444" },];<Gauge arcStyle="solid" zones={zones} value={78} /><Gauge zones={zones} zoneDisplay="fill" totalNotches={60} value={92} /><Gauge arcStyle="solid" zones={zones} zoneDisplay="both" value={92} />

Sectors

sector fills the wedge from the start angle to the value. The default conic gradient brightens toward the leading edge (rendered as a CSS conic-gradient layer behind the SVG); radial brightens toward the rim; none paints a flat color — which can be any SVG paint, including url(#pattern) from a PatternPreset child. opacity is the peak opacity (default 0.85) and innerRadius (fraction of the sector radius) hollows the middle. With centerDisc on, the sector starts at the disc's outer edge automatically.

gradient: "conic"
gradient: "radial"
gradient: "none" + url(#pattern)
<Gauge arcStyle="none" sector progressRing value={68} /><Gauge  arcStyle="solid"  arcThickness={0.02}  sector={{ gradient: "radial", innerRadius: 0.3 }}  value={68}  /><Gauge  arcStyle="none"  progressRing  sector={{ gradient: "none", color: "url(#sector-pattern)", innerRadius: 0.5, opacity: 1 }}  value={68}>  <PatternPreset color="var(--chart-1)" id="sector-pattern" preset="diagonal-up" /></Gauge>

Pattern ids are global to the page — generate one per gauge with useId() when the same gauge renders more than once.

Progress ring

progressRing draws a thin ring just outside the track: the value portion in color (default var(--chart-1)), the remainder in trackColor at trackOpacity. width and gap are fractions of the gauge size.

progressRing
progressRing={{ color, width, gap }}
<Gauge progressRing inactiveFillOpacity={0.35} value={71} /><Gauge  arcStyle="none"  progressRing={{ color: "var(--chart-3)", width: 0.022, gap: 0 }}  value={71}  />

Progress dots

dots fills the inside of the dial with concentric rings of dots that light up to the value. Tune rings, spacing (fraction of size, also the ring gap), dot radius (px), color, dimOpacity / litOpacity, and fadeInward (rings fade toward the center).

dots
dots={{ rings: 7, spacing: 0.032, radius: 2.2 }}
<Gauge arcStyle="solid" dots value={83} /><Gauge  arcStyle="none"  dots={{ rings: 7, spacing: 0.032, radius: 2.2 }}  progressRing  value={83}  />

Glow

glow adds a soft bloom to the fill — lit notches, the solid arc and the progress ring. blur is the radius in px (default 6), intensity the strength 0–1 (default 0.8). It reads best on dark surfaces with a saturated activeFill.

glow
glow={{ blur: 10, intensity: 1 }}
<Gauge activeFill="#38bdf8" glow inactiveFillOpacity={0.25} totalNotches={60} value={74} /><Gauge  activeFill="#a855f7"  arcStyle="solid"  glow={{ blur: 10, intensity: 1 }}  value={74}  />

Center disc

centerDisc draws a ringed disc behind the center label — radius (fraction of size, default 0.19), fill (default var(--background)), stroke, strokeOpacity and strokeWidth (px). It sits above sectors and needles, so a short needle disappears under it and a sector starts at its edge.

centerDisc
centerDisc={{ radius, stroke, strokeWidth }}
<Gauge arcStyle="none" centerDisc sector value={68} /><Gauge  arcStyle="solid"  centerDisc={{ radius: 0.22, stroke: "var(--chart-1)", strokeOpacity: 1, strokeWidth: 2 }}  needle={{ variant: "line", tip: "outer", length: 0.45 }}  value={68}  />

Recipes

Composed dials that combine the layers above. More gauge cards live on Recipes.

Fan duty

Solid arc, outside ruler with end labels, a red-line zone band and a short line needle sitting just inside the track.

<Gauge  activeFill="var(--foreground)"  arcStyle="solid"  centerValue={72}  defaultLabel="Duty %"  formatOptions={{ maximumFractionDigits: 0 }}  inactiveFillOpacity={0.6}  needle={{ variant: "line", length: 0.22, width: 5 }}  ruler={{ position: "outside", ticks: 20, majorEvery: 5, labels: "ends" }}  value={72}  zones={[{ from: 80, to: 100, color: "#ef4444" }]}  />

Speedometer

Dense glowing notches that switch to red past the zone, an outside ruler that stays dim (highlightActive: false) and progress dots behind the fill. The reading is mapped from km/h onto 0–100.

<Gauge  activeFill="#38bdf8"  centerValue={228}  defaultLabel="km/h"  dots={{ color: "#ef4444", rings: 6 }}  formatOptions={{ maximumFractionDigits: 0 }}  glow  inactiveFillOpacity={0.25}  notchCornerRadius={1}  notchLengthPercent={55}  ruler={{ position: "outside", ticks: 26, majorEvery: 2, highlightActive: false }}  spacing={35}  totalNotches={90}  value={(228 / 260) * 100}  zoneDisplay="fill"  zones={[{ from: 78, to: 100, color: "#ef4444" }]}  />

Throughput dial

No track: a conic sector, a thin progress ring, an inside ruler labelled in real units (0–800 tonnes), a triangle needle reaching the outer edge and a disc framing the readout.

<Gauge  arcStyle="none"  centerDisc  centerValue={518}  defaultLabel="tonnes per day"  formatOptions={{ maximumFractionDigits: 0 }}  needle={{ variant: "triangle", tip: "outer", length: 0.62, width: 8 }}  progressRing={{ color: "#38bdf8" }}  ruler={{ ticks: 16, majorEvery: 2, labels: { min: 0, max: 800 } }}  sector={{ color: "#38bdf8" }}  value={(518 / 800) * 100}  />

Props

Gauge

PropTypeDefaultDescription
orientation"arc" | "linear""arc"Arc (default) or horizontal linear notch track
valuenumberrequiredFill level 0–100
centerValuenumber—Optional center statistic (NumberFlow); omit for no label
labelPlacement"top" | "bottom" | "left" | "right""top"Label position for linear gauges (top / bottom recommended)
labelAlign"start" | "center" | "end""start"Horizontal alignment for linear label (left / center / right)
totalNotchesnumber40Notch count
spacingnumber25% gap between notches
notchLengthPercentnumber100Notch depth as % of default (5–100); lower = shorter notches
notchWidthPercentnumber80Linear only — notch width as % of slot
notchCornerRadiusnumber0Corner fillet in px (0 = sharp); large values clamp toward a capsule shape
uniformWidthbooleanfalse (arc) / true (linear)Rectangular notches vs tapered
startAngle / endAnglenumber135 / 405Arc sweep in degrees (arc only)
linearHeightnumber24Bar height in px (linear only)
useGradientbooleanfalsePer-notch color ramp (solid arc: left → right gradient)
activeGradient[string, string]lime → emeraldHex stops for active notches when useGradient
inactiveGradient[string, string]same as activeHex stops for inactive notches when useGradient
activeFill / inactiveFillstringchart-1 / borderSolid, CSS color, or url(#patternId)
activeFillOpacity / inactiveFillOpacitynumber1 / 0.8SVG fill-opacity (0–1) for active / track notches
arcStyle"notches" | "solid" | "none""notches"Arc only — notch track, one rounded stroke, or no track
arcThicknessnumber0.035Arc only — solid stroke thickness as a fraction of size
rulerboolean | GaugeRulerOptions—Arc only — scale ticks (and labels) inside or outside the track
needleboolean | GaugeNeedleVariant | GaugeNeedleOptions—Arc only — pointer; true = "gradient"
zonesGaugeZone[]—Arc only — coloured ranges { from, to, color } on 0–100
zoneDisplay"band" | "fill" | "both""band"How zones render
sectorboolean | GaugeSectorOptions—Arc only — wedge from start to value (conic, radial, flat or pattern)
progressRingboolean | GaugeProgressRingOptions—Arc only — thin value ring around the track
dotsboolean | GaugeDotsOptions—Arc only — concentric dot rings that light up to the value
glowboolean | GaugeGlowOptions—Arc only — soft glow on lit notches, solid arc and progress ring
centerDiscboolean | GaugeCenterDiscOptions—Arc only — ringed disc behind the center label
enterTransitionTransitionzero-bounce spring (visualDuration: 0.9)Motion transition for the fill sweep (and needle, sector, ring, dots)
enterStaggerScalenumber1Scales the delay before the sweep starts (0.25–2.5)
defaultLabelstring"Total"Center label
formatOptionsChartStatFlowFormatstandardNumberFlow format
prefix / suffixstring-Center prefix / suffix
width / heightnumber-Fixed size; omit for responsive
minWidthnumber300 (arc) / 200 (linear)Min width (px) when responsive
classNamestring-Root wrapper
childrenReactNode-Defs (PatternPreset, *Gradient, …)

Sizes given as a "fraction of size" are relative to the smaller of the gauge's width and height, so dials scale cleanly. Every option type is exported from @bklitui/ui/charts (GaugeRulerOptions, GaugeNeedleOptions, …).

GaugeRulerOptions

OptionTypeDefaultDescription
position"inside" | "outside""inside"Inside the track, or ringing it
ticksnumber50Intervals along the sweep (ticks = intervals + 1)
majorEverynumber5Every Nth tick is major
colorstringvar(--foreground)Tick colour
majorLength / minorLengthnumber0.05 / 0.028Tick lengths as a fraction of size
gapnumber0.028Gap between track and ruler (fraction of size)
highlightActivebooleantrueBrighten ticks up to the value
labelsboolean | "majors" | "ends" | GaugeRulerLabelOptions—Numeric labels; true = "majors"

GaugeRulerLabelOptions — show ("majors" | "ends"), min / max (label domain, default 0 / 100), format ((value: number) => string), color (default var(--foreground) at 72% opacity).

GaugeNeedleOptions

OptionTypeDefaultDescription
variant"line" | "gradient" | "triangle" | "polygon""gradient"Rounded stroke · stroke fading in toward the tip · slim triangle · slender diamond
colorstringvar(--foreground)Needle colour
widthnumber2.5 / 4 / 10 / 8Stroke width (line, gradient) or base width (triangle, polygon) in px
lengthnumber0.55Fraction of the reach (center → tip); 1 runs from the pivot
pivotbooleanfalsePivot cap at the center
tip"inner" | "outer" | "edge""inner"Tip just inside the track, at its outer edge, or past the outermost layer

GaugeZone

FieldTypeDescription
from / tonumberRange on the 0–100 scale
colorstringBand / fill colour

GaugeSectorOptions

OptionTypeDefaultDescription
gradient"conic" | "radial" | "none""conic"Brightens toward the leading edge · toward the rim · flat
colorstringvar(--chart-1)Any CSS colour; url(#id) paints work with radial / none
opacitynumber0.85Peak opacity
innerRadiusnumber0Hollow center as a fraction of the sector radius

GaugeProgressRingOptions

OptionTypeDefaultDescription
colorstringvar(--chart-1)Value portion
trackColorstringvar(--muted-foreground)Remainder
trackOpacitynumber0.35Remainder opacity
widthnumber0.01Stroke width (fraction of size)
gapnumber0.022Gap from the track (fraction of size)

GaugeDotsOptions

OptionTypeDefaultDescription
ringsnumber5Concentric rings of dots
spacingnumber0.03Dot and ring spacing (fraction of size)
radiusnumber1.6Dot radius in px
colorstringvar(--chart-1)Dot colour
dimOpacity / litOpacitynumber0.12 / 0.9Opacity past / up to the value
fadeInwardbooleantrueFade rings toward the center

GaugeGlowOptions

OptionTypeDefaultDescription
blurnumber6Blur radius in px
intensitynumber0.8Glow strength 0–1

GaugeCenterDiscOptions

OptionTypeDefaultDescription
radiusnumber0.19Disc radius (fraction of size)
fillstringvar(--background)Disc fill
strokestringvar(--foreground)Ring colour
strokeOpacitynumber0.75Ring opacity
strokeWidthnumber3Ring width in px

Theming

Inactive (track) notches default to var(--border) — shared with ring tracks and radar grid lines. Active notches default to var(--chart-1), as do sectors, progress rings and dots; rulers, needles and the center disc ring use var(--foreground) and the disc fill var(--background), so dials follow light and dark mode. Override with inactiveFill / activeFill, or tune --border / --chart-1 in your theme. See Theming.

Live examples

See the Gauge gallery for arc and linear variants. Use Studio to tune every gauge prop interactively — toggle Linear for the horizontal notch track, Show label for optional center text, and the legend-style Position picker for label placement — then copy the resulting code.