ProgressBar
ProgressBar는 어떤 것이 얼마나 완료되었는지 보여주거나, 전체를 구성하는 부분들을 시각화하는 데 쓰는 간단한 차트 컴포넌트예요. 세그먼트로 전체의 여러 부분을 나타낼 수 있고 애니메이션·크기·색상을 커스터마이즈할 수 있습니다.
출처: 문서
본문
ProgressBar는 진행률을 보여주는 간단한 차트로, 작업 진행 상태를 나타내거나 전체를 이루는 부분들을 시각화하는 데 사용할 수 있습니다. React와 Rails 모두 지원되며 Figma 스펙도 제공됩니다.
React 예제
기본
<ProgressBar progress="33" aria-label="4 of 12 tasks completed" />
보이는 텍스트 값과 함께
ProgressBar를 채워진 세그먼트 값(들)을 명시적으로 보여주는 텍스트와 짝지어 사용하는 것이 기본입니다. 텍스트 값은 필수는 아니지만, 진행률이 의도적으로 모호할 때만 생략해야 합니다.
<>
<ProgressBar progress="33" aria-label="4 of 12 tasks completed" />
<span style={{color: 'var(--fgColor-muted)', font: 'var(--text-body-shorthand-medium)'}}>4 of 12</span>
{/* this span is visually hidden, but conveys context for screen readers */}
<span
style={{
clipPath: 'inset(50%)',
height: '1px',
overflow: 'hidden',
position: 'absolute',
whiteSpace: 'nowrap',
width: '1px',
}}
>
tasks completed
</span>
</>
여러 세그먼트
ProgressBar는 세그먼트를 사용해 전체의 여러 부분을 나타낼 수 있습니다. 여러 세그먼트를 사용할 때는 다음을 따르세요.
- 구분하기 쉬운 색상을 쓰고 각 세그먼트가 무엇을 나타내는지 식별하는 범례(legend)를 포함하세요.
- 세그먼트가 너무 많아 사용자를 압도하지 않게 하세요. 특히 좁은 ProgressBar에서 중요합니다. 이런 경우에는 다른 종류의 차트를 고려하세요.
<>
<ProgressBar aria-valuenow={50}>
<ProgressBar.Item progress={30} style={{backgroundColor: 'var(--bgColor-success-emphasis)'}} aria-label="30%" />
<ProgressBar.Item progress={15} style={{backgroundColor: 'var(--bgColor-accent-emphasis)'}} aria-label="15%" />
<ProgressBar.Item progress={5} style={{backgroundColor: 'var(--bgColor-danger-emphasis)'}} aria-label="5%" />
</ProgressBar>
<Stack direction="horizontal" wrap="wrap" role="presentation">
<Stack direction="horizontal" gap="condensed" align="center">
<DotFillIcon fill="var(--bgColor-success-emphasis)" />
Done
</Stack>
<Stack direction="horizontal" gap="condensed" align="center">
<DotFillIcon fill="var(--bgColor-accent-emphasis)" />
In progress
</Stack>
<Stack direction="horizontal" gap="condensed" align="center">
<DotFillIcon fill="var(--bgColor-danger-emphasis)" />
Closed
</Stack>
</Stack>
</>
애니메이션
<ProgressBar animated progress="33" aria-label="4 of 12 tasks completed" />
커스텀 크기
크기는 ProgressBar를 서로 다른 맥락에 맞게 조절할 수 있습니다. 크기 옵션: Small, Medium(기본), Large. 다음 예제는 'large' 크기 변형을 사용합니다.
<ProgressBar barSize="large" progress="33" aria-label="4 of 12 tasks completed" />
커스텀 색상
ProgressBar의 채워진 세그먼트 색상을 커스터마이즈할 수 있습니다.
<ProgressBar
style={{backgroundColor: 'var(--bgColor-done-emphasis)'}}
progress="33"
aria-label="4 of 12 tasks completed"
/>
더 많은 코드 예제
ProgressBar Storybook 스토리를 참고하세요.
Props
ProgressBar
| 이름 | 기본값 | 타입 | 설명 |
|---|---|---|---|
animated |
boolean |
진행 바의 채워진 영역(들)을 애니메이션할지 여부. | |
progress |
0 |
number |
채워진 바의 크기(진행률)를 설정합니다. |
barSize |
'default' |
'small' | 'large' | 'default' |
진행 바의 높이를 제어합니다. 생략하면 기본 높이로 설정됩니다. |
inline |
false |
boolean |
진행 바를 인라인으로 스타일링합니다. |
bg |
'bg.successInverse' |
string |
진행 바 색상을 설정합니다. |
ProgressBar.Item
| 이름 | 기본값 | 타입 | 설명 |
|---|---|---|---|
aria-label |
string |
현재 요소를 라벨하는 문자열 값을 정의합니다. (@see aria-labelledby) | |
bg |
success.emphasis |
string |
진행 세그먼트 색상을 설정합니다. |
progress |
0 |
string | number |
채워진 바의 크기(진행률)를 설정합니다. |
더 알아보기 (Learn more)
- ProgressBar 접근성 문서에서 ARIA 속성과 테스트 방법을 확인하세요.
- 더 다양한 예제는 ProgressBar Storybook을 참고하세요.
- 여러 세그먼트와 범례를 결합한 시각화 패턴은 GitHub Primer 디자인 가이드를 살펴보세요.