Segment meter Free
Free forever. One command, source you own.
Install
npx shadcn@latest add https://cottoncandy.dev/r/segment-meter.jsonFree. Lands in components/mu/segment-meter/ with the shared foundation. Needs React 19, Tailwind v4 and motion; reads your shadcn theme, and dark mode follows .dark.
Usage
import { SegmentMeter } from "@/components/mu/segment-meter/SegmentMeter";
<SegmentMeter label="AI credits this month" value={7420} max={10000} unit="/ 10k" status="Resets in 9 days" scale />
<SegmentMeter size="md" tone="usage" segments={5} max={5} value={4} valueText="{value} of {max} seats" />Use with an agent Beta
npx shadcn@latest add https://cottoncandy.dev/r/uisdk/segment-meter.jsonOptional. An AI agent in your app can read and set this piece by name, and you can ask before anything it can’t undo. The piece itself doesn’t change. Built on UI SDK 0.1.0-beta.23, which is in beta too, so this add-on follows its releases.
Source
How it works
Building with an agent? Hand it a ready prompt for this piece.
Input and reduced motion
- Pointer: rest on a lamp and its detail shows after 120ms; moving to the next lamp swaps it at once; it closes 200ms after the pointer leaves the body.
- Touch: a tap shows a lamp's detail at once, a second tap hides it.
- Keyboard: with
describe, one Tab stop; Left and Right move between lamps, Home and End jump to the ends, and focus shows the detail at once. - Reduced motion: the lamps light at once with no flash, the figure lands with no roll, and the detail appears without rising.
Props
| Prop | Default | What it does |
|---|---|---|
value | required | 0–max | the count shown; the last lit lamp shows its share of a unit |
max | 100 | > 0 | the full count |
segments | 10 | 1–24 | how many lamps |
size | "lg" | lg 50px, md 16px, sm 8px | the body's height (the meter family's one geometry) |
tone | "heat" | heat, status, usage | the light ramp: heat ember to warm white; status ember to mint (full is good); usage mint to ember (full is bad). Pair it with words: colour never says it alone |
describe | — | (index) => string | a lamp's detail, shown above it on hover (after 120ms) or focus (at once); with it the lamps are focusable and the arrow keys move between them |
active / onActiveChange | — | lamp index or null | the lamp whose detail shows, controlled; fires for every hover, focus and tap |
label | — | text | the label over the figure; with it the meter shows its reading |
unit | — | text | words after the figure ("/ 10k") |
status | — | text | the line under the figure |
scale | false | boolean | the 0 · 25 · 50 · 75 · 100 scale under the body |
valueText | "{value} of {max}" | template | what a screen reader hears (aria-valuetext) |
locale | the page's | BCP 47 | number grouping |
className | — | — | added to the root |
Sound
None. It loads in silence.
None: a meter is read, not pressed.
Licence
Free to use in your projects, under the terms on the licence.
Counted units as a row of lamps that warm up one by one; point at one for its detail.
For quotas, credits and usage limitsMore in Usage & billing