Progress Bar
Progress Bar component shows how much of a task or a multi-step flow is done.
Examples
Default
A bar filled to value out of max (100 by default). Name it with aria-label or aria-labelledby; it is exposed as a progressbar with its range.
1import { ProgressBar } from '@devup-ui/components'
2
3export default function Default() {
4 return <ProgressBar aria-label="Upload progress" value={40} />
5}
61import { ProgressBar } from '@devup-ui/components'
2
3export default function Default() {
4 return <ProgressBar aria-label="Upload progress" value={40} />
5}
6Step
Use variant="step" for a multi-step flow. max is the number of steps and value the steps done; each step gets its own segment.
1import { ProgressBar } from '@devup-ui/components'
2
3export default function Step() {
4 return (
5 <ProgressBar
6 aria-label="Sign-up steps"
7 max={6}
8 showValue
9 value={3}
10 variant="step"
11 />
12 )
13}
141import { ProgressBar } from '@devup-ui/components'
2
3export default function Step() {
4 return (
5 <ProgressBar
6 aria-label="Sign-up steps"
7 max={6}
8 showValue
9 value={3}
10 variant="step"
11 />
12 )
13}
14Show Value
Use showValue to print the progress above the bar: a percent for a bar, done/total for steps. Values outside 0 to max are clamped.
1'use client'
2
3import { Button, ProgressBar } from '@devup-ui/components'
4import { Flex, VStack } from '@devup-ui/react'
5import { useState } from 'react'
6
7export default function ShowValue() {
8 const [value, setValue] = useState(30)
9
10 return (
11 <VStack gap="16px">
12 <ProgressBar aria-label="Download progress" showValue value={value} />
13 <Flex gap="8px">
14 <Button onClick={() => setValue((v) => Math.max(v - 10, 0))}>
15 -10
16 </Button>
17 <Button onClick={() => setValue((v) => Math.min(v + 10, 100))}>
18 +10
19 </Button>
20 </Flex>
21 </VStack>
22 )
23}
241'use client'
2
3import { Button, ProgressBar } from '@devup-ui/components'
4import { Flex, VStack } from '@devup-ui/react'
5import { useState } from 'react'
6
7export default function ShowValue() {
8 const [value, setValue] = useState(30)
9
10 return (
11 <VStack gap="16px">
12 <ProgressBar aria-label="Download progress" showValue value={value} />
13 <Flex gap="8px">
14 <Button onClick={() => setValue((v) => Math.max(v - 10, 0))}>
15 -10
16 </Button>
17 <Button onClick={() => setValue((v) => Math.min(v + 10, 100))}>
18 +10
19 </Button>
20 </Flex>
21 </VStack>
22 )
23}
24Colors
Use the colors prop to change the filled part (primary), the empty part (track) and the value text (text).
1import { ProgressBar } from '@devup-ui/components'
2
3export default function Colors() {
4 return (
5 <ProgressBar
6 aria-label="Storage used"
7 colors={{ primary: '#2CA353', track: '#D9F2E1', text: '#2CA353' }}
8 showValue
9 value={72}
10 />
11 )
12}
131import { ProgressBar } from '@devup-ui/components'
2
3export default function Colors() {
4 return (
5 <ProgressBar
6 aria-label="Storage used"
7 colors={{ primary: '#2CA353', track: '#D9F2E1', text: '#2CA353' }}
8 showValue
9 value={72}
10 />
11 )
12}
13API
ProgressBar props extend the div HTML attributes (except children and role). It renders a progressbar with aria-valuemin, aria-valuemax and aria-valuenow.
| Prop | description | Type | Default |
|---|---|---|---|
| value | How much is done, clamped between 0 and |
| |
| max | The value that means done; the number of steps for the |
|
|
| variant | One continuous bar, or one segment per step |
|
|
| showValue | Whether to show the progress above the bar ( |
|
|
| classNames | Custom class names for inner elements |
|
|
| colors | Custom color variables for the progress bar |
|
|