React Meter
A glass React meter for a level inside a known range, such as storage, battery or password strength, that is spoken as well as colored.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/meter.jsonStorage used
Plenty of room left.
MetergetMeterLeveldefaultMeterLevelLabels- +1 more
Levels
Storage: lower is better (optimum 0), so it goes amber past 70% and red past 90%. Battery: higher is better. CPU updates live; the fill springs and the number counts with it.
Storage used
Storage
46.1 GB of 64 GB used
Battery
CPU
import { Meter } from "@/components/sheenui/meter/meter";
// Package build (after the first npm release, or a packed tarball): import { Meter } from "@sheenui/theme";
export function Example() {
const storage = 82; // percent used
const cpu = 41;
return (
<>
<Meter label="Storage" value={storage} low={70} high={90} optimum={0} showLevel
description={`${(storage * 0.64).toFixed(1)} GB of 64 GB used`} />
<Meter label="Battery" value={18} low={20} high={60} optimum={100} showLevel />
<Meter label="CPU" value={cpu} low={60} high={85} optimum={0} size="sm" />
</>
);
}Files to copy
5 folders · 5 files · 4 packages
- From
theme/src/ components/meter/hooks/{use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, math.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/meter.jsonRegistry item: meter. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Segmented and custom values
variant=segmented draws cells, like a battery or signal meter. format / valueText change the number; levelLabels rename the levels.
Password strength
Bandwidth this month
Signal
import { Meter } from "@/components/sheenui/meter/meter";
// Package build (after the first npm release, or a packed tarball): import { Meter } from "@sheenui/theme";
export function Example() {
const strength = 60; // 0 to 100, from your password checker
return (
<>
<Meter
label="Password strength"
value={strength}
low={40}
high={75}
optimum={100}
variant="segmented"
segments={4}
showLevel
valueText={false}
levelLabels={{ critical: "Weak", suboptimal: "Fair", optimum: "Strong" }}
/>
<Meter label="Bandwidth" value={7.4} max={10} format={{ style: "unit", unit: "gigabyte", maximumFractionDigits: 1 }} />
<Meter label="Signal" value={3} max={5} variant="segmented" segments={5} valueText={(_, v) => `${v} of 5 bars`} />
</>
);
}Props
Keyboard
Accessibility
- role="meter" named by label (or aria-label), described by description, with aria-valuenow, aria-valuemin and aria-valuemax.
- The level (critical, suboptimal, optimum) is part of the spoken value (aria-valuetext) and, with showLevel, written next to the value, so color is never the only signal.
- Use variant="segmented" for battery- or signal-style read-outs; the same spoken value applies.
All exports on this page
Meter— Meter: a measurement within a known range (disk usage, battery, password strength, CPU load).defaultMeterLevelLabels— Default words for each MeterLevel (Good, Warning, Critical).getMeterLevel— Which region the value falls in, by the HTML <meter> algorithm.
When to use Meter
- Use it as a storage usage bar, such as 41 GB of 64 GB, where lower is better and the bar turns amber past 70 percent and red past 90 percent using low, high and optimum.
- Use it for a battery or signal read-out with variant="segmented", which draws cells like a battery icon, and for password strength with levelLabels renamed to Weak and Strong.
- Use it for a live value such as CPU load, where the fill springs to the new level and the number counts with it.
- Skip it when the value shows progress toward completion of a task; Progress is the right component for uploads and steps, because a meter describes a level in a range rather than how far along something is.
- Pair it with Badge to repeat the level in words, Tooltip for the exact value, and GlassCard to group several meters in a dashboard.
Frequently asked questions
Related pages
Guides that cover it
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .