본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

스테퍼

원문 보기 위키 갱신

스테퍼 (Stepper)

스테퍼는 마법사처럼 여러 단계를 거치는 작업 흐름을 사용자에게 안내하는 컴포넌트예요. StepList, Step, StepPanels, StepPanel 컴포넌트를 조합해 구성하고, value 속성으로 각 단계와 내용 패널을 서로 연결해요. 선형(Linear) 진행 방식, 세로 레이아웃, 템플릿 커스터마이징은 물론 키보드 접근성과 디자인 토큰을 활용한 테마 설정까지 폭넓게 다룰 수 있어요.

출처: 문서

본문

접근성

스크린 리더: Stepper 컨테이너는 tablist role로 정의돼요. 모든 속성은 컨테이너 요소에 전달되기 때문에, Stepper를 설명하는 요소를 지정하려면 aria-labelledby를 선택적으로 사용할 수 있어요. 각 스테퍼 헤더는 tab role을 가지며, 해당 스테퍼 콘텐츠 요소를 참조하는 aria-controls도 가지고 있어요. 각 스테퍼의 콘텐츠 요소는 tabpanel role과, 헤더의 aria-controls와 일치하는 id, 그리고 접근 가능한 이름으로서 헤더를 참조하는 aria-labelledby를 가지고 있어요. 탭 헤더 키보드 지원 키 기능 tab 헤더 사이에서 포커스를 이동해요. enter 포커스된 스테퍼 헤더를 활성화해요. space 포커스된 스테퍼 헤더를 활성화해요.

basic-doc

Stepper는 StepList, Step, StepPanels, StepPanel 컴포넌트의 조합으로 구성돼요. value 프로퍼티는 Step과 StepPanel을 서로 연결하는 데 필수적이에요.

import { Component } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { StepperModule } from 'primeng/stepper';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-stepper [value]="1" class="basis-[50rem]">
                <p-step-list>
                    <p-step [value]="1">Header I</p-step>
                    <p-step [value]="2">Header II</p-step>
                    <p-step [value]="3">Header II</p-step>
                </p-step-list>
                <p-step-panels>
                    <p-step-panel [value]="1">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content I</div>
                            </div>
                            <div class="flex pt-6 justify-end">
                                <p-button label="Next" icon="pi pi-arrow-right" iconPos="right" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="2">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content II</div>
                            </div>
                            <div class="flex pt-6 justify-between">
                                <p-button label="Back" severity="secondary" icon="pi pi-arrow-left" (onClick)="activateCallback(1)" />
                                <p-button label="Next" icon="pi pi-arrow-right" iconPos="right" (onClick)="activateCallback(3)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="3">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content III</div>
                            </div>
                            <div class="flex pt-6 justify-start">
                                <p-button label="Back" icon="pi pi-arrow-left" iconPos="right" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-panels>
            </p-stepper>
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, StepperModule]
})
export class StepperBasicDemo {}

리니어

linear 프로퍼티를 true로 설정하면, 다음 단계로 이동하려면 현재 단계를 반드시 완료해야 해요.

import { Component } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { StepperModule } from 'primeng/stepper';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-stepper [value]="1" class="basis-[50rem]" [linear]="true">
                <p-step-list>
                    <p-step [value]="1">Header I</p-step>
                    <p-step [value]="2">Header II</p-step>
                    <p-step [value]="3">Header II</p-step>
                </p-step-list>
                <p-step-panels>
                    <p-step-panel [value]="1">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content I</div>
                            </div>
                            <div class="flex pt-6 justify-end">
                                <p-button label="Next" icon="pi pi-arrow-right" iconPos="right" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="2">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content II</div>
                            </div>
                            <div class="flex pt-6 justify-between">
                                <p-button label="Back" severity="secondary" icon="pi pi-arrow-left" (onClick)="activateCallback(1)" />
                                <p-button label="Next" icon="pi pi-arrow-right" iconPos="right" (onClick)="activateCallback(3)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="3">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content III</div>
                            </div>
                            <div class="flex pt-6 justify-start">
                                <p-button label="Back" icon="pi pi-arrow-left" iconPos="right" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-panels>
            </p-stepper>
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, StepperModule]
})
export class StepperLinearDemo {}

stepsonly

진행 표시기가 필요한 커스텀 요구 사항에서는 StepList만 포함한 Stepper를 사용하세요.

템플릿

Stepper는 기본 UI 디자인을 커스터마이즈할 수 있는 다양한 템플릿 옵션을 제공해요.

import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ButtonModule } from 'primeng/button';
import { PasswordModule } from 'primeng/password';
import { StepperModule } from 'primeng/stepper';
import { ToggleButtonModule } from 'primeng/togglebutton';
import { InputTextModule } from 'primeng/inputtext';

@Component({
    template: `
        <div class="card flex justify-center">
            <p-stepper [(value)]="activeStep" class="basis-[40rem]">
                <p-step-list>
                    <p-step [value]="1" class="flex flex-row flex-auto gap-2">
                        <ng-template #content let-activateCallback="activateCallback" let-value="value">
                            <button class="bg-transparent border-0 inline-flex flex-col gap-2" (click)="activateCallback()">
                                <span
                                    class="rounded-full border-2 w-12 h-12 inline-flex items-center justify-center"
                                    [ngClass]="{
                                        'bg-primary text-primary-contrast border-primary': value <= activeStep,
                                        'border-surface': value > activeStep
                                    }"
                                >
                                    <i class="pi pi-user"></i>
                                </span>
                            </button>
                        </ng-template>
                    </p-step>
                    <p-step [value]="2" class="flex flex-row flex-auto gap-2">
                        <ng-template #content let-activateCallback="activateCallback" let-value="value">
                            <button class="bg-transparent border-0 inline-flex flex-col gap-2" (click)="activateCallback()">
                                <span
                                    class="rounded-full border-2 w-12 h-12 inline-flex items-center justify-center"
                                    [ngClass]="{
                                        'bg-primary text-primary-contrast border-primary': value <= activeStep,
                                        'border-surface': value > activeStep
                                    }"
                                >
                                    <i class="pi pi-star"></i>
                                </span>
                            </button>
                        </ng-template>
                    </p-step>
                    <p-step [value]="3" class="flex flex-row flex-auto gap-2">
                        <ng-template #content let-activateCallback="activateCallback" let-value="value">
                            <button class="bg-transparent border-0 inline-flex flex-col gap-2" (click)="activateCallback()">
                                <span
                                    class="rounded-full border-2 w-12 h-12 inline-flex items-center justify-center"
                                    [ngClass]="{
                                        'bg-primary text-primary-contrast border-primary': value <= activeStep,
                                        'border-surface': value > activeStep
                                    }"
                                >
                                    <i class="pi pi-id-card"></i>
                                </span>
                            </button>
                        </ng-template>
                    </p-step>
                </p-step-list>
                <p-step-panels>
                    <p-step-panel [value]="1">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col gap-2 mx-auto" style="min-height: 16rem; max-width: 20rem">
                                <div class="text-center mt-4 mb-4 text-xl font-semibold">Create your account</div>
                                <div class="field">
                                    <input [(ngModel)]="name" pInputText id="input" type="text" placeholder="Name" fluid />
                                </div>
                                <div class="field">
                                    <input [(ngModel)]="email" pInputText id="email" type="email" placeholder="Email" fluid />
                                </div>
                                <div class="field">
                                    <p-password [(ngModel)]="password" placeholder="Password" fluid />
                                </div>
                            </div>
                            <div class="flex pt-6 justify-end">
                                <p-button (onClick)="activateCallback(2)" label="Next" icon="pi pi-arrow-right" iconPos="right" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="2">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col gap-2 mx-auto" style="min-height: 16rem; max-width: 24rem">
                                <div class="text-center mt-4 mb-4 text-xl font-semibold">Choose your interests</div>
                                <div class="flex flex-wrap justify-center gap-4">
                                    <p-togglebutton [(ngModel)]="option1" onLabel="Nature" offLabel="Nature" />
                                    <p-togglebutton [(ngModel)]="option2" onLabel="Art" offLabel="Art" />
                                    <p-togglebutton [(ngModel)]="option3" onLabel="Music" offLabel="Music" />
                                    <p-togglebutton [(ngModel)]="option4" onLabel="Design" offLabel="Design" />
                                    <p-togglebutton [(ngModel)]="option5" onLabel="Photography" offLabel="Photography" />
                                    <p-togglebutton [(ngModel)]="option6" onLabel="Movies" offLabel="Movies" />
                                    <p-togglebutton [(ngModel)]="option7" onLabel="Sports" offLabel="Sports" />
                                    <p-togglebutton [(ngModel)]="option8" onLabel="Gaming" offLabel="Gaming" />
                                    <p-togglebutton [(ngModel)]="option9" onLabel="Traveling" offLabel="Traveling" />
                                    <p-togglebutton [(ngModel)]="option10" onLabel="Dancing" offLabel="Dancing" />
                                </div>
                            </div>
                            <div class="flex pt-6 justify-between">
                                <p-button (onClick)="activateCallback(1)" label="Back" severity="secondary" icon="pi pi-arrow-left" />
                                <p-button (onClick)="activateCallback(3)" label="Next" icon="pi pi-arrow-right" iconPos="right" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                    <p-step-panel [value]="3">
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col items-center gap-2 mx-auto" style="min-height: 16rem; max-width: 24rem">
                                <div class="text-center mt-4 mb-4 text-xl font-semibold">Account created successfully</div>
                                <div class="text-center">
                                    <img alt="logo" src="https://primefaces.org/cdn/primeng/images/stepper/content.svg" />
                                </div>
                            </div>
                            <div class="flex pt-6 justify-start">
                                <p-button (onClick)="activateCallback(2)" label="Back" severity="secondary" icon="pi pi-arrow-left" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-panels>
            </p-stepper>
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, PasswordModule, StepperModule, ToggleButtonModule, InputTextModule, FormsModule]
})
export class StepperTemplateDemo {
    activeStep: number = 1;
    name: string | undefined = null;
    email: string | undefined = null;
    password: string | undefined = null;
    option1: boolean | undefined = false;
    option2: boolean | undefined = false;
    option3: boolean | undefined = false;
    option4: boolean | undefined = false;
    option5: boolean | undefined = false;
    option6: boolean | undefined = false;
    option7: boolean | undefined = false;
    option8: boolean | undefined = false;
    option9: boolean | undefined = false;
    option10: boolean | undefined = false;
}

세로 레이아웃

세로 레이아웃에서는 Step과 StepPanel 컴포넌트를 감싸는 래퍼로 StepItem이 필요해요.

import { Component } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { StepperModule } from 'primeng/stepper';

@Component({
    template: `
        <div class="card">
            <p-stepper [value]="1">
                <p-step-item [value]="1">
                    <p-step>Header I</p-step>
                    <p-step-panel>
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content I</div>
                            </div>
                            <div class="py-6">
                                <p-button label="Next" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-item>
                <p-step-item [value]="2">
                    <p-step>Header II</p-step>
                    <p-step-panel>
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content II</div>
                            </div>
                            <div class="flex py-6 gap-2">
                                <p-button label="Back" severity="secondary" (onClick)="activateCallback(1)" />
                                <p-button label="Next" (onClick)="activateCallback(3)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-item>
                <p-step-item [value]="3">
                    <p-step>Header III</p-step>
                    <p-step-panel>
                        <ng-template #content let-activateCallback="activateCallback">
                            <div class="flex flex-col h-48">
                                <div class="border-2 border-dashed border-surface-200 dark:border-surface-700 rounded bg-surface-50 dark:bg-surface-950 flex-auto flex justify-center items-center font-medium">Content III</div>
                            </div>
                            <div class="py-6">
                                <p-button label="Back" severity="secondary" (onClick)="activateCallback(2)" />
                            </div>
                        </ng-template>
                    </p-step-panel>
                </p-step-item>
            </p-stepper>
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, StepperModule]
})
export class StepperVerticalDemo {}

Stepper

Stepper는 마법사 방식의 워크플로를 간소화하는 컴포넌트예요. 콘텐츠를 일관된 단계로 구성하고, 다단계 프로세스에서 번호순 진행 과정을 따라 사용자를 시각적으로 안내해요.

프로퍼티

이름 타입 기본값 설명
dt InputSignal undefined 컴포넌트의 스코프 디자인 토큰을 정의해요.
unstyled InputSignal undefined 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요.
pt InputSignal undefined 컴포넌트 내부의 DOM 요소에 속성을 전달할 때 사용해요.
ptOptions InputSignal undefined 컴포넌트의 passthrough(pt) 옵션을 구성할 때 사용해요.
value ModelSignal undefined 숫자 값을 담거나 undefined일 수 있는 모델이에요.
linear InputSignalWithTransform<any, boolean> false 사용자 입력을 담는 불리언 변수예요.
transitionOptions InputSignal 400ms cubic-bezier(0.86, 0, 0.07, 1) 애니메이션의 트랜지션 옵션이에요. (지원 중단됨)
motionOptions InputSignal ... 모션 옵션이에요.

패스 스루 옵션

이름 타입 설명
root PassThroughOption<HTMLElement, I> 루트의 DOM 요소에 속성을 전달할 때 사용해요.
motion MotionOptions 모션 컴포넌트/디렉티브에 옵션을 전달할 때 사용해요.

테마

CSS 클래스

클래스 설명
p-stepper 루트 요소의 클래스 이름
p-stepper-separator 구분자 요소의 클래스 이름

디자인 토큰

토큰 CSS 변수 설명
stepper.transition.duration --p-stepper-transition-duration 루트의 트랜지션 지속 시간
stepper.separator.background --p-stepper-separator-background 구분자의 배경
stepper.separator.active.background --p-stepper-separator-active-background 구분자의 활성 배경
stepper.separator.margin --p-stepper-separator-margin 구분자의 마진
stepper.separator.size --p-stepper-separator-size 구분자의 크기
stepper.step.padding --p-stepper-step-padding 스텝의 패딩
stepper.step.gap --p-stepper-step-gap 스텝의 간격
stepper.step.header.padding --p-stepper-step-header-padding 스텝 헤더의 패딩
stepper.step.header.border.radius --p-stepper-step-header-border-radius 스텝 헤더의 테두리 반경
stepper.step.header.focus.ring.width --p-stepper-step-header-focus-ring-width 스텝 헤더의 포커스 링 너비
stepper.step.header.focus.ring.style --p-stepper-step-header-focus-ring-style 스텝 헤더의 포커스 링 스타일
stepper.step.header.focus.ring.color --p-stepper-step-header-focus-ring-color 스텝 헤더의 포커스 링 색상
stepper.step.header.focus.ring.offset --p-stepper-step-header-focus-ring-offset 스텝 헤더의 포커스 링 오프셋
stepper.step.header.focus.ring.shadow --p-stepper-step-header-focus-ring-shadow 스텝 헤더의 포커스 링 그림자
stepper.step.header.gap --p-stepper-step-header-gap 스텝 헤더의 간격
stepper.step.title.color --p-stepper-step-title-color 스텝 제목의 색상
stepper.step.title.active.color --p-stepper-step-title-active-color 스텝 제목의 활성 색상
stepper.step.title.font.weight --p-stepper-step-title-font-weight 스텝 제목의 글꼴 두께
stepper.step.number.background --p-stepper-step-number-background 스텝 번호의 배경
stepper.step.number.active.background --p-stepper-step-number-active-background 스텝 번호의 활성 배경
stepper.step.number.border.color --p-stepper-step-number-border-color 스텝 번호의 테두리 색상
stepper.step.number.active.border.color --p-stepper-step-number-active-border-color 스텝 번호의 활성 테두리 색상
stepper.step.number.color --p-stepper-step-number-color 스텝 번호의 색상
stepper.step.number.active.color --p-stepper-step-number-active-color 스텝 번호의 활성 색상
stepper.step.number.size --p-stepper-step-number-size 스텝 번호의 크기
stepper.step.number.font.size --p-stepper-step-number-font-size 스텝 번호의 글꼴 크기
stepper.step.number.font.weight --p-stepper-step-number-font-weight 스텝 번호의 글꼴 두께
stepper.step.number.border.radius --p-stepper-step-number-border-radius 스텝 번호의 테두리 반경
stepper.step.number.shadow --p-stepper-step-number-shadow 스텝 번호의 그림자
stepper.steppanels.padding --p-stepper-steppanels-padding steppanels의 패딩
stepper.steppanel.background --p-stepper-steppanel-background steppanel의 배경
stepper.steppanel.color --p-stepper-steppanel-color steppanel의 색상
stepper.steppanel.padding --p-stepper-steppanel-padding steppanel의 패딩
stepper.steppanel.indent --p-stepper-steppanel-indent steppanel의 들여쓰기

더 알아보기 (Learn more)

이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.