Gauge

Notch-based radial gauge with PieCenter-style NumberFlow, theme fills, optional patterns and arc gradients, and responsive sizing

Installation

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

Usage

Gauge draws notches around an arc and uses PieCenterShell so the center matches donut PieChart / PieCenter (NumberFlow + label) without mounting slices.

  • Fill vs center: value is the arc fill 0–100. centerValue is the statistic passed to the center (often the same story or a related KPI).
  • Responsive: omit width and height to fill the parent; the root uses minWidth (default 300) and an aspect ratio so layout stays stable. Pass explicit width / height for fixed layouts.
  • Patterns / gradients in <defs>: pass PatternLines, LinearGradient, etc. as children (same idea as PieChart), 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.
import { Gauge, PatternLines } 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,
      }}
    />
  );
}

Props

Gauge

PropTypeDefaultDescription
valuenumberrequiredArc fill 0–100
centerValuenumberrequiredCenter statistic (NumberFlow)
totalNotchesnumber40Notch count
spacingnumber25% of the arc used as gaps between notches
notchLengthPercentnumber100Radial notch depth as % of default (5–100); lower = shorter notches
notchCornerRadiusnumber0Corner fillet in px (0 = sharp); large values clamp toward a capsule shape
uniformWidthbooleanfalseRectangular notches vs tapered
startAngle / endAnglenumber135 / 405Arc sweep in degrees
useGradientbooleanfalsePer-notch color ramp along the arc
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 / chart-backgroundSolid, CSS color, or url(#patternId)
activeFillOpacity / inactiveFillOpacitynumber1 / 0.8SVG fill-opacity (0–1) for active / track notches
defaultLabelstring"Total"Center label
formatOptionsChartStatFlowFormatstandardNumberFlow format
prefix / suffixstring-Center prefix / suffix
width / heightnumber-Fixed size; omit for responsive
minWidthnumber300Min width (px) when responsive
classNamestring-Root wrapper
childrenReactNode-Defs (Pattern*, *Gradient, …)

Live examples

See the Gauge gallery. Use Studio to tune every gauge prop interactively and copy the resulting code.