Progress
A bar for an operation with a known end: it shows how far along the work is when the fraction is computable, and that the work is running when it is not.
Building your trip
Choosing places in Lisbon
Installation
npx shadcn@latest add @flyingsalmon/progressUsage
import { Progress } from '@/components/ui/progress'
export function ProgressUsage({ percent }: { percent: number }) {
return <Progress value={percent} label="Building your trip" />
}Examples
Determinate
Press Advance. The fill travels from wherever it sits to each new value, so a stream of small steps reads as one continuous movement.
Indeterminate
Omit value for work that has started but has no computable fraction yet, such as the wait before the first progress event. Switch to a number as soon as one exists.
Contacting the planner
Custom max
max lets you count in your own units. A trip that plans seven days counts to seven, and value is clamped to the range, so an off-by-one from a server never draws a bar past its end.
Day 5 of 7 planned
Empty, partial, and full
A full bar keeps the fill colour and does not turn green. The result of the work belongs to the app, in the place the traveller is already looking.
Guidelines
When to use
- For a long job with a known end and nothing to attach it to, such as building a trip.
- For work that has started but has no computable fraction yet, as an indeterminate bar.
When not to use
Do and don’t
- DoSay in words, next to the bar, what phase the work is in.A bar shows how much, never what. Only the app knows what phase the work is in and how to word it.
- DoWhen the work already has a heading on the page, write the count there, such as “3 of 7 days written”, and leave the bar out.The heading is where the traveller is looking, and a bar beside it repeats the count.
- Don’tFake a fraction.A bar that jumps to 90 percent and waits misreports the work. Use the indeterminate bar until a real number exists.
- Don’tShow success or failure on the bar.The bar only measures. The result appears where the traveller is looking: on the item that changed, or in the surface that acted.
Accessibility
The bar is not interactive: it has no hover, press, or disabled state and takes no tab stop.
It is a progressbar with aria-valuemin 0 and aria-valuemax set to max. When determinate it carries aria-valuenow and a screen reader reads a percentage. When indeterminate it carries none, so no percentage is announced before one exists.
label becomes the accessible name and defaults to “Loading”. The bar does not set aria-busy; put that on the region that is waiting.
API
Progress
Also takes every <div> attribute.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | – | The current amount, clamped to 0 through max. Omit it for an indeterminate bar. The bar draws only the fraction, so write the phase and value in words beside it. |
| max | number | 100 | The amount at which the work is complete. |
| label | string | "Loading" | The accessible name of the bar. Name the work whenever more than one bar can be on screen; without it every bar reads as “Loading”. |
The bar carries no outcome. Read data-state, which becomes complete once value reaches max, to react when the work ends.