ProgressLinear
Shows progress as a horizontal bar. It is the most widely used of the three progress components.
import { ProgressLinear } from 'neba';
<ProgressLinear value={64} label="Uploading assets" showValue />
<ProgressLinear />Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value | number | null | null | How far along, between min and max. null(the default) is indeterminate: an indicator that has not been told a value should say so rather than draw an empty bar |
| min | number | 0 | The bottom of the range |
| max | number | 100 | The top of the range |
| sizeshared | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' | Thickness of the groove. Nothing else on a bar has a size |
| colorshared | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'primary' | Semantic colour role |
| label | ReactNode | — | A name for what is loading. Read out with the value by a screen reader |
| showValue | boolean | false | Shows the value as text beside the shape. Percentage of the range unless format says otherwise |
| format | Intl.NumberFormatOptions | — | How to write the value. Without it the value is a percentage of min…max, the only formatting that holds for a range nobody described |
| thickness | number | — | The groove's thickness in pixels, when the step's own is not the one you want. size still sets the type scale beside it |
Native <div> attributes pass through to the root. Only color and children are excluded, since the table above spells them differently.
value defaults to null, the indeterminate state: a short segment travels along the groove. A value of 0 means something different ("nothing has progressed yet"), so keep the two apart.
Examples
size
thickness
size is a step on the library's ladder; thickness is a number of pixels, for the bar a page is actually about. It changes the groove alone — size still sets the type scale of the label beside it.
<ProgressLinear value={62} thickness={12} />min · max · format
The percentage shown is a proportion of min…max, not of 100. showValue prints it beside the bar, and format takes Intl.NumberFormat options so you can show the number itself: bytes, files, currency.
Reduced motion
prefers-reduced-motion does not stop the indeterminate animation. The travelling segment is replaced by a colour pulse across the whole groove.
Accessibility
- Carries
role="progressbar"with the value and range attributes;aria-valuenowis dropped while indeterminate. labelbecomes the accessible name, andaria-valuetextsays the same thing as the printed value.