ProgressBar
ProgressBar는 작업이 시간에 따라 진행되는 정도를 확정적(determinate) 또는 비확정적(indeterminate)으로 보여주는 컴포넌트예요. 해요체로 쉽게 설명드릴게요.
본문
사용법 (Usage)
import { ProgressBar, Label } from '@heroui/react';
{"name": "progress-bar-basic"}
구조 (Anatomy)
import { ProgressBar, Label } from '@heroui/react';
export default () => (
<ProgressBar value={60}>
<Label>Loading</Label>
<ProgressBar.Output />
<ProgressBar.Track>
<ProgressBar.Fill />
</ProgressBar.Track>
</ProgressBar>
);
예시 (Examples)
크기 (Sizes)
{"name": "progress-bar-sizes"}
색상 (Colors)
{"name": "progress-bar-colors"}
라벨 없이 (Without Label)
보이는 라벨이 필요 없을 때는 접근성을 위해 aria-label을 사용해요.
{"name": "progress-bar-without-label"}
비확정 (Indeterminate)
진행률을 알 수 없을 때는 isIndeterminate를 사용해요.
{"name": "progress-bar-indeterminate"}
커스텀 값 범위 (Custom Value Scale)
minValue, maxValue, formatOptions를 사용해 값 범위와 표시 형식을 커스터마이징할 수 있어요.
{"name": "progress-bar-custom-value"}
커스터마이징 (Customization)
Tailwind CSS
{"name": "progress-bar-custom-styles"}
Global CSS
ProgressBar 컴포넌트 클래스를 커스터마이징하려면 @layer components 지시어를 사용할 수 있어요.
더 알아보기.
@layer components {
.progress-bar {
@apply w-full gap-2;
}
.progress-bar__track {
@apply h-3 rounded-full;
}
.progress-bar__fill {
@apply rounded-full;
}
}
스타일링 참고 (Styling Reference)
HeroUI는 BEM 방법론을 따라 컴포넌트 변형과 상태를 재사용하고 쉽게 커스터마이징할 수 있게 해요.
CSS 클래스 (CSS Classes)
ProgressBar 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):
Base & 요소 클래스 [!toc]
.progress-bar- 기본 컨테이너 (그리드 레이아웃).progress-bar__output- 값 텍스트 표시.progress-bar__track- 트랙 배경.progress-bar__fill- 트랙의 채워진 부분
크기 클래스 [!toc]
.progress-bar--sm- 작은 크기 변형 (더 얇은 트랙).progress-bar--md- 중간 크기 변형 (기본값).progress-bar--lg- 큰 크기 변형 (더 두꺼운 트랙)
색상 클래스 [!toc]
.progress-bar--default- 기본 색상 변형.progress-bar--accent- 강조 색상 변형.progress-bar--success- 성공 색상 변형.progress-bar--warning- 경고 색상 변형.progress-bar--danger- 위험 색상 변형
API 참고 (API Reference)
ProgressBar
React Aria ProgressBar에서 상속받아요.
| Prop | Type | Default | Description |
|---|---|---|---|
value |
number |
0 |
The current value |
minValue |
number |
0 |
The minimum value |
maxValue |
number |
100 |
The maximum value |
isIndeterminate |
boolean |
false |
Whether progress is indeterminate |
size |
"sm" | "md" | "lg" |
"md" |
Size of the progress track |
color |
"default" | "accent" | "success" | "warning" | "danger" |
"accent" |
Color of the fill bar |
formatOptions |
Intl.NumberFormatOptions |
{style: 'percent'} |
Number format for the value display |
valueLabel |
ReactNode |
- | Custom value label content |
children |
ReactNode | (values: ProgressBarRenderProps) => ReactNode |
- | Content or render prop |
Render Props
렌더 프롭 패턴을 사용하면 이 값들이 제공돼요:
| Prop | Type | Description |
|---|---|---|
percentage |
number |
The percentage of the progress (0-100) |
valueText |
string |
The formatted value text |
isIndeterminate |
boolean |
Whether progress is indeterminate |