Status
Progress indicator
A progress indicator shows that the app is working on something the person asked for: a bar where the result will appear, or a spinner for a short wait in a small space.
In kanso-ui as ProgressIndicator
Web and native
ProgressIndicator in kanso-ui 0.59.0, for React.
import { ProgressIndicator } from '@kanso-labs/kanso-ui'Progress through a task, drawn as a line or a ring, with a known value or as indeterminate work.
It follows Material Design's progress indicators page: an active indicator in primary over a secondary container track, a stop indicator at the end of the line, 4dp thick with a 4dp gap, in the page's flat and wavy shapes. The indeterminate motion is Material's own; under reduced motion it slows rather than stopping, and a wavy indicator is drawn flat.
What you provide
- A name:
label, shown above the line, oraria-labelwhen the surroundings already say what the work is. valuebetweenminValueandmaxValue, orisIndeterminatewith no value.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
buffer | number | — | How far the work is loaded ahead of the value — a video's buffered seconds, a queue's fetched pages. Read on the same scale as `value`: the track is solid up to it and dotted beyond. One of Material Design's expressive forms, so a line given a buffer is drawn as Material Design draws it, with a 4px gap after the bar and a stop at the end. Ignored while the indicator is indeterminate, and by the ring, which draws no buffer; left out for work with nothing to buffer. |
className | ProgressBarProps['className'] | — | A function may compute the class from the indicator's render state. |
diameter | string | '40px' | How wide the ring is drawn, as a CSS length: 40px unless given, for the flat ring and the wavy one alike. Everything inside scales with it, so `1em` gives a ring the size of the type around it. Kanso's range is 24px to 40px — its spinner in a row or a button, and the one for a region — so stay inside it. Ignored by the line, which fills the width it is given. A length rather than a step of the size scale: a ring sized to the type around it is what the prop is for, and no fixed scale gives that. |
label | ReactNode | — | What the work is, shown above the indicator. A screen reader reads it as the indicator's name; an indicator whose surroundings name it takes `aria-label` instead and leaves this out. |
shape | 'flat' | 'wavy' | 'flat' | `flat` is Kanso's plain bar and ring. `wavy` is Material Design's expressive form: the active indicator drawn as a wave, which lies flat near either end of a determinate value, beside a flat track with Material Design's 4px gap and its stop at the end. Under `prefers-reduced-motion` a wavy indicator is drawn flat, and a wavy line whose length is unknown stands still as Kanso's does. |
showValue | boolean | false | Whether the value is shown at the end of the label's row. Ignored while the indicator is indeterminate, which has no value to show. On a ring the row sits above it, and the indicator is as wide as the wider of the two. |
style | ProgressBarProps['style'] | — | A function may compute the style from the indicator's render state. |
tone | 'accent' | 'inherit' | 'primary' | 'accent' | Which colours it is drawn in. `accent` is Kanso's — the bar in `accent` over a `container` track — and `inherit` takes the colour around it, for an indicator inside something that already has one, such as a button, where the accent would be the fill. `primary` is deprecated: it is Material Design's name for what is now `accent`, and draws the accent. |
variant | 'circular' | 'linear' | 'linear' | The bar or the ring: `linear` fills the width it is given, `circular` is 40px across unless `diameter` says otherwise. |
Also takes the props of Omit<ProgressBarProps, 'children' | 'className' | 'style'>.
Example
import { ProgressIndicator } from '@kanso-labs/kanso-ui'
<ProgressIndicator label="Label" value={40} showValue />
<ProgressIndicator label="Label" value={30} buffer={70} />
<ProgressIndicator aria-label="Label" isIndeterminate variant="circular" />
<ProgressIndicator label="Label" value={40} shape="wavy" />The design’s classes
k-progress, k-progress__bar, k-progress--indeterminate, k-spinner, k-spinner--lg. The label row reuses the meter's head (k-meter__head, k-meter__value), since bundle.css has no label row for progress.
Maps to ProgressIndicator in kanso-ui and react-native-kanso-ui; k-spinner is the Kanso look of LoadingIndicator.