Progress
import { Progress } from "@cherry-design-system/react";
export function Upload() {
return <Progress label="Uploading" value={64} showValue />;
}Progress is a linear bar for work with a known or unknown length, such as an upload or an import. The fill eases to each new value; without a value it slides as an indeterminate loader. For a small inline loading indicator, use Spinner.
Examples
Indeterminate
Omit value (or pass null) when the length of the work is unknown. Without a visible label, name the bar with aria-label.
import { Progress } from "@cherry-design-system/react";
export function Loading() {
return <Progress aria-label="Loading projects" />;
}Variants and sizes
import { Progress } from "@cherry-design-system/react";
export function Variants() {
return (
<>
<Progress label="Storage" value={40} />
<Progress label="Checks passed" value={100} variant="success" />
<Progress label="Quota used" value={95} variant="danger" size="sm" />
</>
);
}Custom max and value format
formatValue receives the value and max and returns the text shown next to the label.
import { Progress } from "@cherry-design-system/react";
export function Files() {
return (
<Progress
label="Files processed"
value={18}
max={40}
showValue
formatValue={(value, max) => `${value} of ${max}`}
/>
);
}Properties
Current value. Omit it, or pass null, for an indeterminate bar.
Value of a full bar. Defaults to 100.
Visible label. It also names the progressbar.
Shows the formatted value next to the label.
Formats the shown value. Defaults to a rounded percentage.
Bar color. Defaults to "default".
Bar thickness: 4px (sm) or 6px (md). Defaults to "md".
Accessible name when there is no visible label.
Progress renders a <div> that holds the header and the role="progressbar" track. It forwards its ref to the root and passes every other <div> attribute through. It has no client JavaScript, so it is safe in Server Components.
Styling
| Hook | Values |
|---|---|
.cherry-progress | Root element |
data-variant | default, success, danger |
data-size | sm, md |
data-indeterminate | Present when there is no value |
| Parts | .cherry-progress__header, __label, __value, __track, __fill |
The track reads --cherry-bg-muted. The fill reads --cherry-primary-default, --cherry-success-solid or --cherry-danger-solid. Motion is reduced under prefers-reduced-motion.
Accessibility
The bar is a role="progressbar" with its value and range. Give it a label or an aria-label. value={null} marks it indeterminate.