Gauge
A single value against a range, with optional colored bands such as healthy, slow and failing.
Status: beta. Category: Data display.
import { Gauge } from '@glyphui/ui/chart'
Exports: Gauge.
Notes
- Renders as role="meter" with the value, range and band name, e.g. “240 ms, Slow”.
- The arc sweeps in on mount and when the value changes, at the theme’s motion level.
Gauge props
| Prop | Type | Default | Description |
|---|---|---|---|
title (required) | string | Accessible name, also the caption. | |
value (required) | number | ||
bands | readonly GaugeBand[] | Colored ranges, e.g. healthy / slow / failing. The value arc takes its band's color. | |
className | string | ||
color | ChartColorValue | Color of the value arc when there are no bands. Default chart-1. | |
description | ReactNode | ||
hideTitle | boolean | ||
label | ReactNode | Small text under the value, e.g. "p95 latency". | |
max | number | 100 | |
min | number | 0 | |
size | number | 220 | Width in pixels. Default 220. |
valueFormatter | ((value: number) => string) | (value: number) => typeof value === 'number' && Number.isFinite(value) ? value.toLocaleString() : String(value) |
Example: With bands
The arc takes the color of its band.
import { Gauge } from '@glyphui/ui/chart'
export default function Example() {
return (
<Gauge
title="API latency"
description="p95, last 15 minutes"
value={238}
max={600}
valueFormatter={(v) => `${v} ms`}
bands={[
{ to: 200, color: 'success', label: 'Healthy' },
{ to: 400, color: 'warning', label: 'Slow' },
{ to: 600, color: 'danger', label: 'Failing' },
]}
/>
)
}
Example: Quota used
import { Button } from '@glyphui/ui'
import { Gauge } from '@glyphui/ui/chart'
import { useState } from 'react'
export default function Example() {
const [used, setUsed] = useState(7.4)
return (
<div className="grid justify-items-center gap-3">
<Gauge
title="Storage"
value={used}
max={10}
valueFormatter={(v) => `${v.toFixed(1)} GB`}
label="of 10 GB used"
size={200}
/>
<Button variant="outline" size="sm" onClick={() => setUsed((v) => (v > 9 ? 2.1 : v + 0.8))}>
Upload files
</Button>
</div>
)
}
Live page: https://glyphui.xyz/components/gauge