프로그레스바
프로그레스바 (ProgressBar)
프로그레스바는 작업의 진행 상태를 시각적으로 보여주는 컴포넌트예요. value 속성으로 기본 사용이 가능하고, 값이 반응형으로 바뀌는 동적 표시나 값이 정해지지 않은 작업을 위한 indeterminate 모드도 지원해요. 또한 content 템플릿으로 진행 막대 안에 원하는 콘텐츠를 넣을 수 있고, 스크린 리더를 위한 ARIA 속성까지 갖춰 접근성도 챙겨줘요
출처: 문서
본문
접근성
스크린 리더 관점에서 ProgressBar 컴포넌트는 progressbar 역할과 함께 aria-valuemin, aria-valuemax, aria-valuenow 속성을 사용해요. 컴포넌트를 설명하는 값은 aria-labelledby와 aria-label props로 정의할 수 있어요.
기본
ProgressBar는 value 프로퍼티와 함께 사용해요.
import { Component } from '@angular/core';
import { ProgressBarModule } from 'primeng/progressbar';
@Component({
template: `
<div class="card">
<p-progressbar [value]="50" />
</div>
`,
standalone: true,
imports: [ProgressBarModule]
})
export class ProgressbarBasicDemo {}
동적
value는 반응형이기 때문에 동적으로 업데이트하면 바도 함께 바뀌어요.
import { Component, OnInit, inject } from '@angular/core';
import { ProgressBarModule } from 'primeng/progressbar';
import { ToastModule } from 'primeng/toast';
import { MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<p-toast />
<p-progressbar [value]="value" />
</div>
`,
standalone: true,
imports: [ProgressBarModule, ToastModule],
providers: [MessageService]
})
export class ProgressbarDynamicDemo implements OnInit {
private messageService = inject(MessageService);
value: number = 0;
interval: any;
ngOnInit() {
this.ngZone.runOutsideAngular(() => {
this.interval = setInterval(() => {
this.ngZone.run(() => {
this.value = this.value + Math.floor(Math.random() * 10) + 1;
if (this.value >= 100) {
this.value = 100;
this.messageService.add({ severity: 'info', summary: 'Success', detail: 'Process Completed' });
clearInterval(this.interval);
}
});
}, 2000);
});
}
ngOnDestroy() {
if (this.interval) {
clearInterval(this.interval);
}
}
}
인디터미네이트
추적할 값이 없는 진행 상황이라면 mode 프로퍼티를 indeterminate로 설정하세요.
import { Component, inject } from '@angular/core';
import { ProgressBarModule } from 'primeng/progressbar';
import { MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<p-progressbar mode="indeterminate" [style]="{ height: '6px' }" />
</div>
`,
standalone: true,
imports: [ProgressBarModule],
providers: [MessageService]
})
export class ProgressbarIndeterminateDemo {
private messageService = inject(MessageService);
}
템플릿
content 템플릿을 사용하면 progressbar 안에 커스텀 콘텐츠를 표시할 수 있어요.
import { Component } from '@angular/core';
import { ProgressBarModule } from 'primeng/progressbar';
@Component({
template: `
<div class="card">
<p-progressbar [value]="50">
<ng-template #content let-value>
<span>{{ value }}/100</span>
</ng-template>
</p-progressbar>
</div>
`,
standalone: true,
imports: [ProgressBarModule]
})
export class ProgressbarTemplateDemo {}
프로그레스 바
ProgressBar는 프로세스 상태 표시기예요.
프롭스
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 요소에 속성을 전달하는 데 사용해요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용해요. |
| value | number | - | 진행 상태의 현재 값이에요. |
| showValue | boolean | true | 프로그레스 바 값을 표시할지 여부예요. |
| styleClass | string | - | 요소의 스타일 클래스예요. (지원 중단) |
| valueStyleClass | string | - | value 요소의 스타일 클래스예요. |
| unit | string | % | 값 뒤에 붙는 단위 기호예요. |
| mode | "indeterminate" | "determinate" | 'determinate' | 진행의 모드를 정의해요 |
| color | string | - | 진행 배경의 색상이에요. |
템플릿
| 이름 | 타입 | 설명 |
|---|---|---|
| content | TemplateRef | 콘텐츠의 템플릿이에요. |
패스 스루 옵션
| 이름 | 타입 | 설명 |
|---|---|---|
| host | PassThroughOption<HTMLElement, I> | 호스트의 DOM 요소에 속성을 전달하는 데 사용해요. |
| root | PassThroughOption<HTMLDivElement, I> | 루트의 DOM 요소에 속성을 전달하는 데 사용해요. |
| value | PassThroughOption<HTMLDivElement, I> | value의 DOM 요소에 속성을 전달하는 데 사용해요. |
| label | PassThroughOption<HTMLDivElement, I> | label의 DOM 요소에 속성을 전달하는 데 사용해요. |
테마
CSS 클래스
| 클래스 | 설명 |
|---|---|
| p-progressbar | 루트 요소의 클래스 이름 |
| p-progressbar-value | value 요소의 클래스 이름 |
| p-progressbar-label | label 요소의 클래스 이름 |
디자인 토큰
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| progressbar.background | --p-progressbar-background | 루트의 배경 |
| progressbar.border.radius | --p-progressbar-border-radius | 루트의 테두리 반경 |
| progressbar.height | --p-progressbar-height | 루트의 높이 |
| progressbar.value.background | --p-progressbar-value-background | value의 배경 |
| progressbar.label.color | --p-progressbar-label-color | label의 색상 |
| progressbar.label.font.size | --p-progressbar-label-font-size | label의 글자 크기 |
| progressbar.label.font.weight | --p-progressbar-label-font-weight | label의 글자 두께 |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.