Documentation / Display & media
ProgressBar
A horizontal progress bar for a task whose progress is known (value, from 0 to 100, clamped to that range) or not (indeterminate). Five sizes, six colours and three styles: solid, striped (striped) or gradient (gradient).
The track carries role="progressbar" with aria-valuenow (absent in indeterminate mode); label serves as both the visible title and the accessible name: give it one, or name the bar with aria-labelledby / aria-label when the page already shows its label — they go to the track, not to the wrapper. showValue shows the percentage, which valueFormat can replace. progressColor and trackColor replace the colours of the fill and of the track. No hooks, server-compatible.
Examples
Basic usage
A value, a label and the percentage shown on the right.
import { ProgressBar } from "@synertech/ui";
export function Basic() {
return <ProgressBar value={64} label="Import des contacts" showValue />;
}Sizes and colours
size sets the track thickness, color the fill hue.
import { ProgressBar } from "@synertech/ui";
export function SizesAndColors() {
return (
<div className="space-y-4">
<ProgressBar value={30} size="xs" color="default" label="Très fine" />
<ProgressBar value={50} size="sm" color="info" label="Fine" />
<ProgressBar value={70} size="lg" color="success" label="Épaisse" />
<ProgressBar value={90} size="xl" color="warning" label="Très épaisse" />
</div>
);
}Styles
striped adds stripes, gradient replaces the flat fill with a gradient.
import { ProgressBar } from "@synertech/ui";
export function Variants() {
return (
<div className="space-y-4">
<ProgressBar value={55} size="lg" variant="striped" label="Hachurée" />
<ProgressBar value={55} size="lg" variant="gradient" label="Dégradé" />
</div>
);
}Unknown duration
indeterminate runs a segment with no value, and hides the percentage.
import { ProgressBar } from "@synertech/ui";
export function Indeterminate() {
return <ProgressBar indeterminate label="Connexion au serveur…" />;
}Value format
valueFormat receives the clamped value and returns the text to display.
import { useEffect, useState } from "react";
import { ProgressBar } from "@synertech/ui";
export function CustomFormat() {
const [value, setValue] = useState(0);
useEffect(() => {
const timer = setInterval(
() => setValue((current) => (current >= 100 ? 0 : current + 10)),
600
);
return () => clearInterval(timer);
}, []);
return (
<ProgressBar
value={value}
label="Envoi des fichiers"
showValue
valueFormat={(v) => `${Math.round((v / 100) * 24)} / 24 fichiers`}
/>
);
}Brand colour and a label of the page
progressColor and trackColor replace the colours of color; aria-labelledby names the bar with a text the page already shows, without repeating it.
import { ProgressBar } from "@synertech/ui";
export function BrandColor() {
return (
<div className="max-w-md space-y-2">
<p id="generation-progress" className="text-sm font-medium">
Génération : 3 documents sur 10 (30 %)
</p>
<ProgressBar
value={30}
aria-labelledby="generation-progress"
progressColor="bg-orange-600 dark:bg-orange-500"
trackColor="bg-orange-100 dark:bg-orange-950"
/>
</div>
);
}Subscription quotas
The colour follows the threshold: the label stays readable, the hue is only reinforcement.
import { ProgressBar } from "@synertech/ui";
const quotas = [
{ label: "Stockage", used: 42 },
{ label: "Utilisateurs", used: 78 },
{ label: "Appels API", used: 96 },
];
export function Quotas() {
return (
<div className="max-w-md space-y-4">
{quotas.map((quota) => (
<ProgressBar
key={quota.label}
value={quota.used}
label={quota.label}
showValue
color={quota.used >= 90 ? "error" : quota.used >= 75 ? "warning" : "primary"}
/>
))}
</div>
);
}API reference
Components
import { ProgressBar } from "@synertech/ui";Props — ProgressBarProps
| Prop | Type | Default | Description |
|---|---|---|---|
animated |
boolean |
true |
|
aria-describedby |
string |
— | Id of the element that describes the bar. Goes to the element that holds the |
aria-label |
string |
— | Accessible name of the bar. Goes to the element that holds the |
aria-labelledby |
string |
— | Id of the element that names the bar: a label the page already shows. Goes to the element that holds the |
aria-valuetext |
string |
— | The value as a reader should hear it, when a percentage is not it: |
color |
ProgressBarColor |
"primary" |
|
indeterminate |
boolean |
false |
|
label |
string |
— | Text shown above the bar, which also names it. A page that already shows a label of its own names the bar with |
progressColor |
string |
— | Classes that colour the fill, in place of the ones |
showValue |
boolean |
false |
|
size |
ProgressBarSize |
"md" |
|
trackColor |
string |
— | Classes that colour the track behind the fill, in place of the grey one. |
value |
number |
0 |
|
valueFormat |
(value: number) => string |
— | |
variant |
ProgressBarVariant |
"default" |
+ 273 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).
Types
ProgressBarColor
Typetype ProgressBarColor = "default" | "primary" | "success" | "warning" | "error" | "info"ProgressBarSize
Typetype ProgressBarSize = "xs" | "sm" | "md" | "lg" | "xl"type ProgressBarVariant = "default" | "striped" | "gradient"