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

스텝스

원문 보기 위키 갱신

스텝스 (Steps)

Steps는 워크플로우의 진행 단계를 한눈에 보여주는 인디케이터 컴포넌트로, Stepper라고도 불려요 메뉴 아이템 배열을 모델로 받아 기본 사용법부터 activeIndex를 활용한 프로그래밍 방식 제어와 라우터 연동까지 차근차근 살펴봐요 반응형 레이아웃에 최적화되어 있고, 키보드 접근성 지원과 디자인 토큰을 활용한 테마 설정 방법도 함께 확인할 수 있어요

출처: 문서

본문

접근성

스크린 리더 Steps 컴포넌트는 nav 엘리먼트를 사용하고, 모든 속성이 루트에 암묵적으로 전달되기 때문에 컴포넌트를 설명하려면 aria-labelledby나 aria-label을 사용할 수 있어요. 내부에는 순서 있는 목록이 사용되며, 현재 단계 항목은 aria-current를 "step"으로 정의해요. 키보드 지원 키 기능 tab 포커스가 컴포넌트 안으로 이동하면 활성 단계에 포커스를 추가하고, 이미 포커스된 탭 헤더가 있다면 페이지 탭 순서에 따라 컴포넌트 밖으로 포커스를 이동시켜요. enter readonly가 활성화되어 있지 않으면 포커스된 단계를 활성화해요. space readonly가 활성화되어 있지 않으면 포커스된 단계를 활성화해요. right arrow readonly가 활성화되어 있지 않으면 다음 단계로 포커스를 이동해요. left arrow readonly가 활성화되어 있지 않으면 이전 단계로 포커스를 이동해요. home readonly가 활성화되어 있지 않으면 첫 번째 단계로 포커스를 이동해요. end readonly가 활성화되어 있지 않으면 마지막 단계로 포커스를 이동해요.

기본

Steps는 모델로 menuitems 컬렉션을 필요로 해요.

<p-steps [model]="items" [readonly]="true" />

제어

Steps는 activeIndex 프로퍼티를 사용해서 프로그래밍 방식으로 제어할 수 있어요.

<div class="flex mb-8 gap-2 justify-end">
    <p-button (click)="active = 0" [rounded]="true" label="1" styleClass="w-8 h-8 p-0" [outlined]="active !== 0" />
    <p-button (click)="active = 1" [rounded]="true" label="2" styleClass="w-8 h-8 p-0" [outlined]="active !== 1" />
    <p-button (click)="active = 2" [rounded]="true" label="3" styleClass="w-8 h-8 p-0" [outlined]="active !== 2" />
</div>
<p-steps [activeIndex]="active" [model]="items" />
TypeScript 예제
import { Component, OnInit } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { StepsModule } from 'primeng/steps';
import { MenuItem } from 'primeng/api';

@Component({
    template: `
        <div class="card">
            <div class="flex mb-8 gap-2 justify-end">
                <p-button (click)="active = 0" [rounded]="true" label="1" styleClass="w-8 h-8 p-0" [outlined]="active !== 0" />
                <p-button (click)="active = 1" [rounded]="true" label="2" styleClass="w-8 h-8 p-0" [outlined]="active !== 1" />
                <p-button (click)="active = 2" [rounded]="true" label="3" styleClass="w-8 h-8 p-0" [outlined]="active !== 2" />
            </div>
            <p-steps [activeIndex]="active" [model]="items" />
        </div>
    `,
    standalone: true,
    imports: [ButtonModule, StepsModule]
})
export class StepsControlledDemo implements OnInit {
    items: MenuItem[] | undefined;
    active: number = 0;

    ngOnInit() {
        this.items = [
            {
                label: 'Personal Info'
            },
            {
                label: 'Reservation'
            },
            {
                label: 'Review'
            }
        ];
    }
}

인터랙티브

컴포넌트에 인터랙티브 기능을 추가하려면 readonly를 비활성화하고, activeIndex 바인딩을 activeIndexChange와 함께 사용해서 Steps를 제어하세요.

<p-toast />
<p-steps [model]="items" [readonly]="false" [activeIndex]="activeIndex" (activeIndexChange)="onActiveIndexChange($event)" />
TypeScript 예제
import { Component, OnInit } from '@angular/core';
import { Steps, StepsModule } from 'primeng/steps';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';

@Component({
    template: `
        <div class="card">
            <p-toast />
            <p-steps [model]="items" [readonly]="false" [activeIndex]="activeIndex" (activeIndexChange)="onActiveIndexChange($event)" />
        </div>
    `,
    standalone: true,
    imports: [StepsModule, ToastModule]
})
export class StepsInteractiveDemo implements OnInit {
    items: MenuItem[] | undefined;
    activeIndex: number = 0;

    constructor(public messageService: MessageService) {}

    ngOnInit() {
        this.items = [
            {
                label: 'Personal',
                command: (event: any) => this.messageService.add({ severity: 'info', summary: 'First Step', detail: event.item.label })
            },
            {
                label: 'Seat',
                command: (event: any) => this.messageService.add({ severity: 'info', summary: 'Second Step', detail: event.item.label })
            },
            {
                label: 'Payment',
                command: (event: any) => this.messageService.add({ severity: 'info', summary: 'Third Step', detail: event.item.label })
            },
            {
                label: 'Confirmation',
                command: (event: any) => this.messageService.add({ severity: 'info', summary: 'Last Step', detail: event.item.label })
            }
        ];
    }
}

라우팅

아래 예제는 Steps와 함께 중첩 라우트를 사용해요.

<p-toast />
<p-steps [model]="items" [readonly]="false" />
TypeScript 예제
import { Component, OnInit } from '@angular/core';
import { Steps, StepsModule } from 'primeng/steps';
import { ToastModule } from 'primeng/toast';
import { TicketService } from '@/service/ticketservice';
import { MenuItem, MessageService } from 'primeng/api';

@Component({
    template: `
        <div class="card">
            <p-toast />
            <p-steps [model]="items" [readonly]="false" />
        </div>
        <router-outlet></router-outlet>
    `,
    standalone: true,
    imports: [StepsModule, ToastModule],
    providers: [TicketService]
})
export class StepsRoutingDemo implements OnInit {
    items: MenuItem[];
    subscription: Subscription;

    constructor(public messageService: MessageService, public ticketService: TicketService) {}

    ngOnInit() {
        this.items = [
            {
                label: 'Personal',
                routerLink: ''
            },
            {
                label: 'Seat',
                routerLink: 'seat'
            },
            {
                label: 'Payment',
                routerLink: 'payment'
            },
            {
                label: 'Confirmation',
                routerLink: 'confirmation'
            }
        ];
        this.subscription = this.ticketService.paymentComplete$.subscribe((personalInformation) => {
            this.messageService.add({
                severity: 'success',
                summary: 'Order submitted',
                detail: 'Dear, ' + personalInformation.firstname + ' ' + personalInformation.lastname + ' your order completed.'
            });
        });
    }

    ngOnDestroy() {
        if (this.subscription) {
            this.subscription.unsubscribe();
        }
    }

    nextPage() {
        this.ticketService.ticketInformation.paymentInformation = this.paymentInformation;
        this.router.navigate(['steps/confirmation']);
    }

    prevPage() {
        this.router.navigate(['steps/seat']);
    }

    setVagons(event) {
        if (this.seatInformation.class && event.value) {
            this.vagons = [];
            this.seats = [];
            for (let i = 1; i < 3 * event.value.factor; i++) {
                this.vagons.push({ wagon: i + event.value.code, type: event.value.name, factor: event.value.factor });
            }
        }
    }

    setSeats(event) {
        if (this.seatInformation.wagon && event.value) {
            this.seats = [];
            for (let i = 1; i < 10 * event.value.factor; i++) {
                this.seats.push({ seat: i, type: event.value.type });
            }
        }
    }

    complete() {
        this.ticketService.complete();
    }
}

테마

디자인 토큰

토큰 CSS 변수 설명
steps.transition.duration --p-steps-transition-duration 루트의 전환 지속 시간
steps.separator.background --p-steps-separator-background 구분선의 배경
steps.item.link.border.radius --p-steps-item-link-border-radius 아이템 링크의 테두리 반경
steps.item.link.focus.ring.width --p-steps-item-link-focus-ring-width 아이템 링크의 포커스 링 너비
steps.item.link.focus.ring.style --p-steps-item-link-focus-ring-style 아이템 링크의 포커스 링 스타일
steps.item.link.focus.ring.color --p-steps-item-link-focus-ring-color 아이템 링크의 포커스 링 색상
steps.item.link.focus.ring.offset --p-steps-item-link-focus-ring-offset 아이템 링크의 포커스 링 오프셋
steps.item.link.focus.ring.shadow --p-steps-item-link-focus-ring-shadow 아이템 링크의 포커스 링 그림자
steps.item.link.gap --p-steps-item-link-gap 아이템 링크의 간격
steps.item.label.color --p-steps-item-label-color 아이템 라벨의 색상
steps.item.label.active.color --p-steps-item-label-active-color 아이템 라벨의 활성 색상
steps.item.label.font.weight --p-steps-item-label-font-weight 아이템 라벨의 글꼴 두께
steps.item.number.background --p-steps-item-number-background 아이템 번호의 배경
steps.item.number.active.background --p-steps-item-number-active-background 아이템 번호의 활성 배경
steps.item.number.border.color --p-steps-item-number-border-color 아이템 번호의 테두리 색상
steps.item.number.active.border.color --p-steps-item-number-active-border-color 아이템 번호의 활성 테두리 색상
steps.item.number.color --p-steps-item-number-color 아이템 번호의 색상
steps.item.number.active.color --p-steps-item-number-active-color 아이템 번호의 활성 색상
steps.item.number.size --p-steps-item-number-size 아이템 번호의 크기
steps.item.number.font.size --p-steps-item-number-font-size 아이템 번호의 글꼴 크기
steps.item.number.font.weight --p-steps-item-number-font-weight 아이템 번호의 글꼴 두께
steps.item.number.border.radius --p-steps-item-number-border-radius 아이템 번호의 테두리 반경
steps.item.number.shadow --p-steps-item-number-shadow 아이템 번호의 그림자

더 알아보기 (Learn more)

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