compacto-ui

Search documentation

Jump to a page or a component.

Progress

Split bar — filled run, gap, remainder; each end collapses to a pip.

Preview

Descriptions75%
Descriptions100%
Descriptions0%

Installation

No install — ask an AI agent to copy this component from registry.json.

import { Progress, progressVariants } from "@/components/ui/progress";

Notes

  • The bar is two objects, not one: the fill stops a gap short of the value and the remainder starts a gap after it, both ends round.
  • Neither segment ever vanishes — each collapses to a single pip the height of the track at its own extreme. The trailing pip at max flips to the accent colour as the 'done' mark; the leading pip at 0 keeps an empty bar from going blank.
  • Because both pips have to fit inside the caller's width, the track is laid out calc(100% - 2 * (gap + pip)) wide and centred, with each segment overhanging its own end. Do not add overflow-hidden to the wrapper; it would clip them.
  • value={null} is the indeterminate state: the split makes no sense without a value, so the track becomes a solid channel with a segment sweeping across it. The keyframe ships in this library's styles — it is not tw-animate-css.
  • Values outside 0..max are clamped rather than overflowing the track.
  • formatValue feeds both the visible readout and the bar's aria-valuetext, so the two cannot disagree.
  • A caller's data-testid lands on the wrapper. The internals are reachable as [data-slot="progress-track"] / -indicator / -remainder.

Props

The props worth knowing. Everything else passes straight through to the underlying element, including className, which is merged last so it always wins.

PropTypeDefaultDescription
valuenumber | nullnullCurrent value. null is the indeterminate sweep.
maxnumber100Value that counts as complete.
labelReactNode—Header copy on the left. Pass a translated string; no default.
showValuebooleanlabel !== undefinedRender the formatted readout on the right of the header row.
formatValue(value: number, max: number) => stringrounded percentageReadout string, and the aria-valuetext with it.
size"sm" | "default" | "lg""default"Track height; the gap and pip derive from it.