Updated
Gauge Dial
Elevated
Customize
Value68
Target80
Accent
Installation
npx shadcn@latest add https://uibrik.com/r/gauge-dial.jsonInstall the packages
npm install @number-flow/react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/gauge-dial/gauge-dial.tsx"use client"; import { useEffect, useId, useState, type CSSProperties, type KeyboardEvent, type PointerEvent, type ReactNode } from "react"; import { motion, useReducedMotion, useSpring, useTransform } from "motion/react"; import NumberFlow from "@number-flow/react"; import { cn } from "@/lib/utils"; // ─── Small helpers, kept here so this file stands alone ───────────────────────── // The arc reads --series-1; the same palette step the other charts use. const ACCENT = "[--series-1:#2a78d6] dark:[--series-1:#3987e5]"; const STATUS = { good: "#22c55e", warning: "#f5a524", critical: "#ef4444" } as const; type Status = keyof typeof STATUS; /** The empty part of the track: the foreground at low strength. */ const TRACK = "color-mix(in srgb, var(--foreground) 7%, transparent)"; type ValueFormat = Intl.NumberFormatOptions & { notation?: "standard" | "compact" }; const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v)); const formatValue = (value: number, format: ValueFormat = {}) => new Intl.NumberFormat("en-US", format).format(value); /** Short form for tight labels: 12,900 becomes "12.9K". */ const formatCompact = (value: number, format: ValueFormat = {}) => new Intl.NumberFormat("en-US", { ...format, notation: "compact", maximumFractionDigits: 1, minimumFractionDigits: 0 }).format(value); /** Lets an `accent` colour replace the arc's colour. */ const accentVars = (accent?: string): CSSProperties | undefined =>
Adds the files to
components/uibrik/gauge-dial and installs @number-flow/react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/gauge-dial.Usage
import { GaugeDial } from "@/components/uibrik/gauge-dial/gauge-dial";<GaugeDial title="CPU load" value={68} unit="% used" target={80} showZone interactive accent="" min={0} max={100} step={1} format={{}} onChange={(value) => {}} // zones={[{ to: 0, label: "…", status: "good" }]}/>Where to use Gauge Dial
Targets and thresholds
A 240-degree dial with a spring-driven knob makes setting a value feel physical.
Pairs with Gauge
Smart-home controls
Lit ticks and a zone badge suit thermostats, fans and other device settings.
Pairs with Tactile Toggle
Budget limits
Dragging or using arrow keys sets a cap precisely while the zone shows if it is safe.
Props
GaugeDial- title
- Type string
- "CPU load"
- Names what is measured.
- value
- Type number
- 68
- Current value. The dial follows it with a spring.
- unit
- Type string
- "% used"
- Small caption under the number.
- target
- Type number
- 80
- A level to aim for, marked outside the arc.
- showZone
- Type boolean
- true
- Names the zone the value is in, in the card's corner.
- interactive
- Type boolean
- true
- Drag the knob or use the arrow keys.
- accent
- Type string
- ""
- Arc colour. Empty uses the chart palette.
- min
- Type number
- 0
- Value at the start of the sweep.
- max
- Type number
- 100
- Value at the end of the sweep.
- zones
- Type { to: number; label: string; status: "good" | "warning" | "critical" }[]
- –
- Named ranges, in order. Empty uses healthy, elevated and critical at 60% and 85% of the range.
- step
- Type number
- 1
- Snap size when dragging or using the keyboard.
- format
- Type Intl.NumberFormatOptions
- {}
- Formats the number.
- onChange
- Type (value: number) => void
- –
- Called as the value changes by drag or keyboard.
- className
- Type string
- –
- Classes for the outer shell.