Segmented Progress
Discrete per-step progress meter — N equal pill segments in a row, each individually expressing done, current, or pending state, with optional step labels and a failed state.
Default
Pass total and value to render a row of pill segments. Completed steps (indices 0..value-1) are filled with the primary color; remaining steps render as muted surface.
With current segment
Pass current (a 0-based index, typically equal to value) to render an in-progress gradient on the next segment — a primary-to-muted split at the ~55%/45% mark.
Sizes
Two segment heights for different surface densities. sm (6px) is the default and matches the brand-workbench prototype. md (8px) is slightly taller for increased visual weight.
Completion states
Each segment independently resolves to done, current, or pending:
Step labels
Pass steps to put a label under each segment. A done step's label carries a check, the current
step's reads bold in the primary ink, and a step not reached reads in the tertiary ink. On mount
each filled segment draws in from the left, once, about 140ms after the one before it; under
prefers-reduced-motion the fills are drawn static.
A step without a state follows value and current, so
<SegmentedProgress value={1} current={1} steps={[{ label: 'A' }, { label: 'B' }, { label: 'C' }]} />
draws done, current, pending.
Failed step
A failed step fills with --interactive-destructive-bg, and its label reads bold in
--text-error with a warning icon.
Sections
A multi-step form's step bar. Give each step a weight (its slide count, say) and its segment
takes that share of the width. Give a finished step an onSelect and it becomes a button that
jumps back to it; steps without one stay out of the tab order. Set fill (0 to 1) on the current
step to fill its segment as far as the form has got through it. With revealLabels, a pending
step's label is hidden, and fades, rises and sharpens in when its step fills. Labels already
filled on first render show without animating, and under prefers-reduced-motion they switch with
no transition. Press Next to walk the form, and press a finished section to jump back.
In Five Looks
The same sections bar in each look, on the theme picked in the docs. The labels take the theme's
text inks. Over a photo (data-glass="on") they take the glass layer's control ink, as the glass
controls beside them do, and the track takes the glass fill and blurs
the photo behind it; everywhere else the track is solid and does not blur.
Theming the steps
| Hook | Default | Drives |
|---|---|---|
--button-strong-fill | --interactive-primary-bg | The current segment's fill, with or without steps |
--segmented-progress-sm-label-font-size | --font-size-xs (12px) | Labels under sm |
--segmented-progress-md-label-font-size | --font-size-sm (14px) | Labels under md |
--segmented-progress-fill-duration | 600ms | Each segment's fill-in |
--segmented-progress-fill-stagger | 140ms | The delay between one segment's fill and the next |
--motion-duration-enter, --motion-easing-enter | --motion-duration-800, --motion-easing-ease-out | A revealed label's fade in |
--glass-control-ink, --glass-fill, --glass-blur | the theme's text inks, --surface-muted, none | Labels, track and track blur under data-glass="on" |
A host that wants smaller labels at desktop widths sets the label hooks in its own media or container query.
Installation
npx visor add segmented-progressThis copies two files into your project:
components/ui/segmented-progress/segmented-progress.tsx— the componentcomponents/ui/segmented-progress/segmented-progress.module.css— the styles
Usage
import { SegmentedProgress } from '@/components/ui/segmented-progress/segmented-progress';
export default function OnboardingProgress({ step, total }: { step: number; total: number }) {
return (
<SegmentedProgress
total={total}
value={step}
current={step}
aria-label={`Step ${step + 1} of ${total}`}
/>
);
}API Reference
SegmentedProgressProps
| Prop | Type | Default | Description |
|---|---|---|---|
total* | number | — | Total number of segments to render. |
value* | number | — | Count of completed segments — indices 0..value-1 render in the done state. With steps, the default for a step that sets no state. |
steps | { label: ReactNode; state?: 'done' | 'current' | 'pending' | 'failed'; weight?: number; onSelect?: () => void; fill?: number }[] | — | One entry per step: a segment with its label under it. The bar is then aria-hidden and summary is read in its place; total and aria-label are not used. weight (default 1) is the step's share of the width; onSelect makes the step a button, for jumping back to a finished step; fill (0 to 1, default 0.55) is how far a current step is filled. |
revealLabels | boolean | false | With steps, hides each pending label and fades it in when its step fills. Labels filled on first render show without animating. |
summary | ReactNode | — | With steps, the visually hidden line a screen reader hears. Defaults to "Step 2 of 3: Bank Details", naming the failed, current or next step. |
current | number | — | Optional 0-based index of the in-progress segment, rendered with the primary-to-muted gradient. Typically equals value. |
size | 'sm' | 'md' | 'sm' | Segment height — 6px (sm) or 8px (md). |
aria-label* | string | — | Accessible name for the progress bar. Not used with steps. |
className | string | — | Additional CSS class names to merge onto the element. |
The component also accepts all standard <div> HTML attributes.
Accessibility
- Without
steps, the root element hasrole="progressbar"witharia-valuemin={0},aria-valuemax={total}, andaria-valuenow={value}. - A step with
onSelectis a<button>named "Go to" and its label (when the label is a string), and it stays in the accessibility tree and the tab order. Every other step isaria-hiddenand never focusable. - With
steps, every other step isaria-hiddenand a visually hidden line beside the bar is read instead: "Step 2 of 3: Bank Details" by default, naming the failed step first, then the current one, then the next one ("All 3 steps done" when every step is done). Passsummaryto say it differently. - Without
steps, anaria-labelis required — describe the current step context (e.g."Step 3 of 10"or"Brand elicitation: step 3 of 10 complete"). - Individual segment
<span>elements are presentational; the progressbar role carries all announcements. - Segment transitions and the fill-in animation are disabled under
prefers-reduced-motion.