진행 바 (ProgressBar)
프로세스 완료 상태를 표시하는 스타일 없는 진행 바 컴포넌트예요.
출처: 문서
본문
Features (기능)
- 하위 컴포넌트(
Root, Track, Indicator, Label, Value)를 갖춘 컴파운드 API예요.
value를 설정 가능한 min/max 범위로 0-100 퍼센트로 정규화해요.
- 진행 상황을 알거나 모를 때 각각 결정적(determinate)/비결정적(indeterminate) 모드를 지원해요.
- 커스텀 표시 텍스트를 위한 설정 가능한
formatter 함수를 지원해요.
Usage (사용법)
import { ProgressBar } from 'primereact/progressbar';
<ProgressBar.Root>
<ProgressBar.Track>
<ProgressBar.Indicator>
<ProgressBar.Label>
<ProgressBar.Value />
</ProgressBar.Label>
</ProgressBar.Indicator>
</ProgressBar.Track>
</ProgressBar.Root>
Behavior (동작)
다형성 렌더링 (Polymorphic Rendering)
어떤 하위 컴포넌트든 as를 써서 렌더링되는 HTML 요소를 바꿀 수 있어요.
<ProgressBar.Root as="section"></ProgressBar.Root>
<ProgressBar.Track as="span"></ProgressBar.Track>
기본 요소: Root=div, Track=div, Indicator=div, Label=div, Value=span이에요.
렌더 함수 children (Render Function Children)
Root는 children으로 렌더 함수를 받아 컴포넌트 인스턴스에 접근할 수 있게 해줘요.
<ProgressBar.Root value={50}>{(instance) => <span>{instance.state.computedValue}%</span>}</ProgressBar.Root>
API
ProgressBarRoot
| Attribute |
Value |
data-scope |
"progressbar" |
data-part |
"root" |
| Label |
Type |
Description |
| root |
ProgressBarRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
| label |
ProgressBarRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the label's DOM element. |
| value |
ProgressBarRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the value's DOM element. |
| track |
ProgressBarRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the track's DOM element. |
| indicator |
ProgressBarRootPassThroughType<HTMLAttributes> |
Used to pass attributes to the indicator's DOM element. |
ProgressBarTrack
| Attribute |
Value |
data-scope |
"progressbar" |
data-part |
"track" |
| Label |
Type |
Description |
| root |
ProgressBarTrackPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
ProgressBarIndicator
| Attribute |
Value |
data-scope |
"progressbar" |
data-part |
"indicator" |
| Label |
Type |
Description |
| root |
ProgressBarIndicatorPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
ProgressBarLabel
| Attribute |
Value |
data-scope |
"progressbar" |
data-part |
"label" |
| Label |
Type |
Description |
| root |
ProgressBarLabelPassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
ProgressBarValue
| Attribute |
Value |
data-scope |
"progressbar" |
data-part |
"value" |
| Label |
Type |
Description |
| root |
ProgressBarValuePassThroughType<HTMLAttributes> |
Used to pass attributes to the root's DOM element. |
Accessibility (접근성)
스크린 리더 (Screen Reader)
ProgressBar 컴포넌트는 progressbar role에 aria-valuemin, aria-valuemax, aria-valuenow 속성을 사용해요. 컴포넌트를 설명하는 값을 aria-labelledby와 aria-label props로 정의할 수 있어요.
<span id="label_status" />
<ProgressBar.Root aria-labelledby="label_status" />
<ProgressBar.Root aria-label="Status" />
키보드 지원 (Keyboard Support)
해당 사항 없음.
더 알아보기 (Learn more)