Meter
shadcn-htmx/meterFreeComponent
The native <meter> element (ARIA role="meter") — a gauge of a value within a known range with low/high/optimum zoning. Cross-browser fill colors via the meter pseudo-elements; includes an htmx live-gauge demo.
Live preview
live · rendered by the registry
Rendered by shadcn-htmx on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-htmx.productdevbook.com/r/meter.jsonSource
1/** @jsxImportSource hono/jsx */2import type { Child } from "hono/jsx"3import { cn, type ClassValue } from "@/registry/lib/cn"45// Meter — shadcn-htmx, htmx v4 + Tailwind v4.6//7// Source of truth:8// shadcn/ui ships no Meter component. This is a native-platform addition9// distinct from Progress: a gauge of a value within a known range10// (battery, disk usage, score) — NOT task completion.11//12// We render the real native <meter> element (implicit role="meter"), so the13// browser supplies the role + value semantics and AT announces the gauge.14// repos/mdn/files/en-us/web/html/reference/elements/meter/index.md15// - value/min/max/low/high/optimum attributes (lines 33-48)16// - "Implicit ARIA role: meter" and "Permitted ARIA roles: No role17// permitted" (lines 123-134) — so we DO NOT set role/aria-value*; the18// element maps value/min/max onto aria-valuenow/min/max itself.19//20// APG: WAI-ARIA Meter pattern21// repos/aria-practices/content/patterns/meter/meter-pattern.html22// - Keyboard Interaction: "Not applicable" (line 46) — a meter is not23// interactive; no JS keyboard contract.24// - Accessible name via aria-labelledby (visible label) or aria-label25// (lines 61-64). We pair with a native <label for> in the docs.26// - aria-valuetext for human-readable values, e.g. "50% (6 hours)27// remaining" (lines 56-59) — surfaced via the `valuetext` prop.28//29// Cross-browser styling note: WebKit/Blink expose ::-webkit-meter-* and30// Gecko exposes ::-moz-meter-bar. Both need `appearance: none` to accept31// custom styles. Those pseudo-elements can't take Tailwind classes, so the32// fill/track theming lives in app/styles/input.css scoped to33// [data-slot="meter"]. Tailwind utilities here only size the box.3435const meterBase =36 "block h-2 w-full overflow-hidden rounded-full bg-primary/20 align-middle"3738export function meterClasses(opts?: { class?: ClassValue }): string {39 return cn(meterBase, opts?.class)40}4142type MeterProps = {43 // Current value. Clamped by the browser to [min, max].44 value: number45 min?: number46 max?: number47 // Lower/upper bounds of the "low" and "high" zones. Combined with optimum48 // they drive the optimum / suboptimum / even-less-good fill color.49 low?: number50 high?: number51 optimum?: number52 id?: string53 // Free-form units hint. The WHATWG HTML spec notes <meter> has no units54 // attribute and that title is the only standard way to convey units55// … truncated
More from shadcn-htmx
All 83 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | shadcn-htmx | Components | Free | no deps | |
| Active Searchactive-search | shadcn-htmx | Components | Free | no deps | |
| Alertalert | shadcn-htmx | Components | Free | no deps | |
| Alert Dialogalert-dialog | shadcn-htmx | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | shadcn-htmx | Components | Free | no deps | |
| Auto Gridauto-grid | shadcn-htmx | Components | Free | no deps | |
| Autocompleteautocomplete | shadcn-htmx | Components | Free | no deps | |
| Autosize Textareaautosize-textarea | shadcn-htmx | Components | Free | no deps |
