组件 · 反馈
Progress
A bar that shows how far a measurable task has gone, such as an upload or usage against a limit, with a label and its value.
也叫 ProgressBar, Loading
import { Progress } from "@botiverse/raft-ui";A progress bar shows how far something with a known percentage has gone: an upload, a file being processed, usage against a quota. Next to it, a label says what it is and how far it has got. Which loading indicator fits which wait is in Choosing a component.
When to use
| Situation | Use |
|---|---|
| The percentage is known | Progress |
| The duration is unknown | Spinner, not a progress bar |
| The layout of what is loading is known | Skeleton |
Anatomy
Progress: the root; takes thevalue. Required.ProgressHeader: an optional row above the track, holdingProgressLabel(what it is) andProgressValue(how far, in Space Mono).ProgressTrack: thefill-mutedtrack. Required.ProgressIndicator: the fill, a sticker with an ink edge. Required.
Variants
| Variant | Use for |
|---|---|
The default (variant="primary") | Progress of any kind: an info fill |
variant="warning" | Usage at 90% of a limit or more |
| Complete | When value reaches the maximum the fill turns success on its own |
- Don't use
variant="danger": reaching a limit interrupts, it isn't irreversible (Color). informationandaccentare the same as the default. Use the default.
States
- Don't show a bar whose percentage can't be computed. Use a Spinner instead of a fake or indeterminate bar.
Content
- Name what is in progress in
ProgressLabel: "Uploading design-crop.png", "Agent hours this month". - Show how far it has got in
ProgressValue, as a percentage or as an amount out of the limit.
Accessibility
Progress wraps Base UI's Progress, which gives it role="progressbar" and its value.
ProgressLabelgives the bar its accessible name. Without a visible label, passaria-labeltoProgress.- Keep
ProgressLabeleven when you leave outProgressValue.
Rules
- Put a bar inside a file card, thumbnail or other rounded container on its own thin track, never along its edge (Shape).
API
Progress
| Prop | 类型 | 默认值 |
|---|---|---|
| "sm" | "md" | "lg" | "md" | |
| "primary" | "accent" | "warning" | "danger" | "information" | "success" | "primary" | |
| A string value that provides a user-friendly name for `aria-valuenow`, the current value of the progress bar. | string | |
| Options to format the value. | Intl.NumberFormatOptions | |
| Accepts a function which returns a string value that provides a human-readable text alternative for the current value of the progress bar. | (formattedValue: string, value: number | null) => string | |
| The locale used by `Intl.NumberFormat` when formatting the value. Defaults to the user's runtime locale. | string | Intl.Locale | readonly (string | Intl.Locale)[] | |
| The maximum value. | number | 100 |
| The minimum value. | number | 0 |
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) | |
| The current value. The component is indeterminate when value is `null`. | number |
Also takes the attributes of its element.
ProgressHeader
接受其元素的全部属性。
ProgressIndicator, ProgressLabel, ProgressTrack
| Prop | 类型 | 默认值 |
|---|---|---|
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.
ProgressValue
| Prop | 类型 | 默认值 |
|---|---|---|
| (formattedValue: string | null, value: number | null) => React.ReactNode | ||
| Allows you to replace the component's HTML element with a different tag, or compose it with another component. | ReactElement | ((props, state) => ReactElement) |
Also takes the attributes of its element.