Progress Bar

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.

Show Code
1import { ProgressBar } from '@devup-ui/components'
2
3export default function Default() {
4    return <ProgressBar aria-label="Upload progress" value={40} />
5}
6
1import { ProgressBar } from '@devup-ui/components'
2
3export default function Default() {
4    return <ProgressBar aria-label="Upload progress" value={40} />
5}
6

Step 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.

Show Code
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}
14
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}
14

Show 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.

Show Code
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}
24
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}
24

Colors Use the colors prop to change the filled part (primary), the empty part (track) and the value text (text).

Show Code
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}
13
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}
13
API

ProgressBar props extend the div HTML attributes (except children and role). It renders a progressbar with aria-valuemin, aria-valuemax and aria-valuenow.

PropdescriptionTypeDefault
value

How much is done, clamped between 0 and max

number

max

The value that means done; the number of steps for the step variant

number

100

variant

One continuous bar, or one segment per step

'bar' | 'step'

'bar'

showValue

Whether to show the progress above the bar (50%, or 3/6 for steps)

boolean

false

classNames

Custom class names for inner elements

{
track?: string

indicator?: string

value?: string

}

undefined

colors

Custom color variables for the progress bar

{
primary?: string

track?: string

text?: string

}

undefined