Progress Bar
Progress Bar 컴포넌트는 작업이나 여러 단계로 이루어진 흐름이 얼마나 진행되었는지 보여 줍니다.
예제
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는 div HTML 속성(children, role 제외)을 확장합니다. aria-valuemin, aria-valuemax, aria-valuenow를 갖춘 progressbar를 렌더링합니다.
| 속성 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| value | 완료된 정도. 0과 |
| |
| max | 완료를 의미하는 값. |
|
|
| variant | 하나로 이어진 막대 또는 단계별 세그먼트 |
|
|
| showValue | 막대 위에 진행 상황을 표시할지 여부( |
|
|
| classNames | 내부 요소에 적용할 사용자 정의 클래스 이름 |
|
|
| colors | 프로그레스 바의 사용자 정의 색상 변수 |
|
|