탐색

v2.1.0
탐색

단계

결제나 초기 설정처럼 짧은 절차에서 현재 위치를 번호 목록으로 표시합니다.

이 페이지의 내용

단계 컴포넌트는 결제나 설정처럼 짧은 절차에서 사용자가 어디까지 진행했는지 보여 줍니다. 순서가 있는 목록을 사용하며, 각 단계의 표식에는 CSS 카운터로 번호를 매깁니다. 현재 단계에만 aria-current="step"을 지정하면 스타일시트가 나머지 단계의 상태를 결정합니다.

단계

<ol class="steps">  <li class="steps-item"><span class="steps-title">Account</span></li>  <li class="steps-item" aria-current="step"><span class="steps-title">Billing</span></li>  <li class="steps-item"><span class="steps-title">Confirm</span></li></ol>
<ol className="steps">  <li className="steps-item"><span className="steps-title">Account</span></li>  <li className="steps-item" aria-current="step"><span className="steps-title">Billing</span></li>  <li className="steps-item"><span className="steps-title">Confirm</span></li></ol>
<ol class="steps">  <li class="steps-item"><span class="steps-title">Account</span></li>  <li class="steps-item" aria-current="step"><span class="steps-title">Billing</span></li>  <li class="steps-item"><span class="steps-title">Confirm</span></li></ol>
<template>  <ol class="steps">    <li class="steps-item"><span class="steps-title">Account</span></li>    <li class="steps-item" aria-current="step"><span class="steps-title">Billing</span></li>    <li class="steps-item"><span class="steps-title">Confirm</span></li>  </ol></template>

#속성 하나로 표현하는 상태

속성 하나로 세 가지 상태를 표현합니다.

  • 현재 단계에는 aria-current="step"을 지정합니다. 표식은 잉크색 윤곽선이 있는 작은 볼록한 표면으로 표시됩니다.
  • 현재 단계보다 앞에 있는 단계는 완료 상태가 됩니다(.steps-item:has(~ .steps-item[aria-current="step"])). 표식은 체크 모양으로 뚫린 잉크색 원입니다. 뚫린 부분으로 아래 표면이 드러나 두 테마 모두에서 체크 표시를 알아볼 수 있고, 다음 단계로 이어지는 선은 잉크색으로 바뀝니다.
  • 나머지 단계는 모두 대기 상태이며, 오목한 영역에 번호가 표시됩니다.

속성을 다음 항목으로 옮기면 세 상태가 모두 갱신됩니다. 절차가 끝나면 현재 단계가 없어집니다. 목록에 steps-complete를 추가하면 모든 단계가 완료 상태로 표시됩니다.

완료

<ol class="steps steps-complete">  <li class="steps-item"><span class="steps-title">Account</span></li>  <li class="steps-item"><span class="steps-title">Billing</span></li>  <li class="steps-item"><span class="steps-title">Confirm</span></li></ol>
<ol className="steps steps-complete">  <li className="steps-item"><span className="steps-title">Account</span></li>  <li className="steps-item"><span className="steps-title">Billing</span></li>  <li className="steps-item"><span className="steps-title">Confirm</span></li></ol>
<ol class="steps steps-complete">  <li class="steps-item"><span class="steps-title">Account</span></li>  <li class="steps-item"><span class="steps-title">Billing</span></li>  <li class="steps-item"><span class="steps-title">Confirm</span></li></ol>
<template>  <ol class="steps steps-complete">    <li class="steps-item"><span class="steps-title">Account</span></li>    <li class="steps-item"><span class="steps-title">Billing</span></li>    <li class="steps-item"><span class="steps-title">Confirm</span></li>  </ol></template>

#세로 배치

steps-vertical 클래스는 단계를 세로로 배치합니다. 열이 좁거나 단계마다 문장 하나가 들어갈 때 사용하세요. 텍스트를 steps-body로 감싸고 steps-description을 추가하세요.

세로 배치

<ol class="steps steps-vertical max-w(320) mx-auto">  <li class="steps-item">    <span class="steps-body">      <span class="steps-title">Create the project</span>      <span class="steps-description">Named atlas, in the Master workspace.</span>    </span>  </li>  <li class="steps-item" aria-current="step">    <span class="steps-body">      <span class="steps-title">Connect a repository</span>      <span class="steps-description">Choose where the code lives.</span>    </span>  </li>  <li class="steps-item">    <span class="steps-body">      <span class="steps-title">Deploy</span>      <span class="steps-description">The first build takes about a minute.</span>    </span>  </li></ol>
<ol className="steps steps-vertical max-w(320) mx-auto">  <li className="steps-item">    <span className="steps-body">      <span className="steps-title">Create the project</span>      <span className="steps-description">Named atlas, in the Master workspace.</span>    </span>  </li>  <li className="steps-item" aria-current="step">    <span className="steps-body">      <span className="steps-title">Connect a repository</span>      <span className="steps-description">Choose where the code lives.</span>    </span>  </li>  <li className="steps-item">    <span className="steps-body">      <span className="steps-title">Deploy</span>      <span className="steps-description">The first build takes about a minute.</span>    </span>  </li></ol>
<ol class="steps steps-vertical max-w(320) mx-auto">  <li class="steps-item">    <span class="steps-body">      <span class="steps-title">Create the project</span>      <span class="steps-description">Named atlas, in the Master workspace.</span>    </span>  </li>  <li class="steps-item" aria-current="step">    <span class="steps-body">      <span class="steps-title">Connect a repository</span>      <span class="steps-description">Choose where the code lives.</span>    </span>  </li>  <li class="steps-item">    <span class="steps-body">      <span class="steps-title">Deploy</span>      <span class="steps-description">The first build takes about a minute.</span>    </span>  </li></ol>
<template>  <ol class="steps steps-vertical max-w(320) mx-auto">    <li class="steps-item">      <span class="steps-body">        <span class="steps-title">Create the project</span>        <span class="steps-description">Named atlas, in the Master workspace.</span>      </span>    </li>    <li class="steps-item" aria-current="step">      <span class="steps-body">        <span class="steps-title">Connect a repository</span>        <span class="steps-description">Choose where the code lives.</span>      </span>    </li>    <li class="steps-item">      <span class="steps-body">        <span class="steps-title">Deploy</span>        <span class="steps-description">The first build takes about a minute.</span>      </span>    </li>  </ol></template>

사용자가 이전 단계로 돌아갈 수 있다면 완료된 단계의 제목을 링크로 만드세요. 대기 중인 단계는 일반 텍스트로 표시하세요.

단계 제목 링크

<nav aria-label="Checkout">  <ol class="steps">    <li class="steps-item"><a class="steps-title link link-quiet" href="#cart">Cart</a></li>    <li class="steps-item"><a class="steps-title link link-quiet" href="#shipping">Shipping</a></li>    <li class="steps-item" aria-current="step"><span class="steps-title">Payment</span></li>    <li class="steps-item"><span class="steps-title">Review</span></li>  </ol></nav>
<nav aria-label="Checkout">  <ol className="steps">    <li className="steps-item"><a className="steps-title link link-quiet" href="#cart">Cart</a></li>    <li className="steps-item">      <a className="steps-title link link-quiet" href="#shipping">Shipping</a>    </li>    <li className="steps-item" aria-current="step"><span className="steps-title">Payment</span></li>    <li className="steps-item"><span className="steps-title">Review</span></li>  </ol></nav>
<nav aria-label="Checkout">  <ol class="steps">    <li class="steps-item"><a class="steps-title link link-quiet" href="#cart">Cart</a></li>    <li class="steps-item"><a class="steps-title link link-quiet" href="#shipping">Shipping</a></li>    <li class="steps-item" aria-current="step"><span class="steps-title">Payment</span></li>    <li class="steps-item"><span class="steps-title">Review</span></li>  </ol></nav>
<template>  <nav aria-label="Checkout">    <ol class="steps">      <li class="steps-item"><a class="steps-title link link-quiet" href="#cart">Cart</a></li>      <li class="steps-item">        <a class="steps-title link link-quiet" href="#shipping">Shipping</a>      </li>      <li class="steps-item" aria-current="step"><span class="steps-title">Payment</span></li>      <li class="steps-item"><span class="steps-title">Review</span></li>    </ol>  </nav></template>

#접근성

  • <ol> 요소를 사용하세요. 항목의 순서 자체에 의미가 있으며, 목록을 통해 전체 단계 수를 알 수 있습니다.
  • aria-current="step"은 보조 기술에 어느 단계가 현재 단계인지 알려 줍니다. 체크 표시와 잉크색은 시각적으로만 전달되므로, 스크린 리더 사용자는 목록 순서로 어느 단계까지 완료되었는지 파악합니다.
  • 가로 배치에서는 짧은 제목을 붙인 단계 4~5개까지만 표시하세요. 단계가 더 많다면 steps-vertical 클래스를 사용하세요.

#클래스

클래스설명
steps단계 목록은 ol에 둡니다. CSS 카운터가 각 표식에 번호를 매기고, 선이 각 표식을 다음 표식에 연결합니다.
steps-vertical좁은 열에 넣거나 단계마다 설명 문장이 있을 때 각 단계를 세로로 배치합니다적용할 클래스는 steps입니다
steps-complete모든 단계가 완료되었으며 현재 진행 중인 단계는 없습니다.적용할 클래스는 steps입니다
steps-item단계를 나타내는 li에 적용합니다. 대기 중인 단계의 표식은 오목한 영역 안의 숫자로 표시합니다. 현재 단계보다 앞선 단계에는 체크 표시가 있는 전경색 원을 표시합니다.
steps-body제목과 설명이 모두 있는 단계에서 두 요소를 함께 감쌉니다.
steps-title단계 이름은 한 줄로 표시하며, 세로 목록에서는 줄바꿈합니다
steps-description제목 아래에 낮은 강조도로 표시하는 한 줄 문구입니다.

#사용자 지정 속성

속성기본값설명
--steps-marker1.5rem표식 지름

#소스

@master/ui/components/steps.css
/* * Steps: where a reader is in a short sequence. An ordered list whose markers are numbered by a CSS counter. * Only the current step is marked, with aria-current="step": the steps before it are complete and take ink * and a check, and the steps after it wait in a well. A line joins each marker to the next. When the whole * sequence is done, steps-complete on the list completes every step. */@layer components.ui {  .steps {    --steps-marker: 1.5rem;    --steps-gap: .75rem;    display: flex;    gap: var(--steps-gap);    min-width: 0;    margin: 0;    padding: 0;    color: var(--color-text-muted);    font-size: .8125rem;    line-height: 1.4;    list-style: none;    counter-reset: steps;    /* Every step is done: none is current, and the list rests in body ink. */    &.steps-complete {      color: var(--color-text-body);    }    /* One step under another, for a narrow column or steps that carry a sentence each. */    &.steps-vertical {      flex-direction: column;      gap: 0;    }  }  .steps-item {    position: relative;    display: flex;    flex: 1 1 0;    align-items: center;    gap: .5rem;    min-width: 0;    counter-increment: steps;    /*     * The last step has nothing to lead to, so it takes only the room it needs; where there is less, it still     * shrinks, so its title is cut like the others' instead of running out of the list.     */    &:last-child {      flex: 0 1 auto;    }    /* The marker: a number in a well while the step waits. */    &::before {      content: counter(steps);      display: grid;      flex: none;      place-items: center;      width: var(--steps-marker);      height: var(--steps-marker);      border-radius: 999px;      background: var(--color-surface-inset);      color: var(--color-text-muted);      box-shadow: var(--shadow-pressed);      font: var(--font-weight-control) .71875rem/1 var(--font-family-sans);      font-variant-numeric: tabular-nums;    }    /* The line to the next step. */    &:not(:last-child)::after {      content: '';      flex: 1 1 1rem;      min-width: 1rem;      height: 1px;      background: var(--color-line-divider);    }    /* Current: the marker rises as a small sheet with an ink contour, and the words take strong ink. */    &[aria-current="step"] {      color: var(--color-text-strong);      &::before {        @apply --surface-sheet;        color: var(--color-text-strong);        box-shadow: 0 0 0 .5px var(--color-text-strong), 0 0 0 1px color-mix(in oklab, var(--color-text-strong) 22%, transparent), 0 1px 2px -1px var(--color-shade-1), 0 2px 4px -2px var(--color-shade-2);      }    }    /*     * Complete: every step that has the current one after it, or every step once the list is marked     * steps-complete. An ink disc with the check cut out of it, so the mark is the surface showing through     * and reads on moonstone and obsidian alike.     */    &:is(:has(~ .steps-item[aria-current="step"]), .steps-complete .steps-item) {      color: var(--color-text-body);      &::before {        content: '';        background: var(--color-surface-inverse);        box-shadow: none;        mask:          url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 8.4 2.6 2.6 5.4-6'/%3E%3C/svg%3E") center / .875rem no-repeat,          linear-gradient(black, black);        mask-composite: exclude;      }      &::after {        background: var(--color-text-strong);      }    }    @media (forced-colors: active) {      &::before {        outline: 1px solid CanvasText;        outline-offset: -1px;      }      &[aria-current="step"]::before {        outline: 2px solid Highlight;      }      /* The ink disc would be forced to the canvas, and its check with it: it keeps the text color instead. */      &:is(:has(~ .steps-item[aria-current="step"]), .steps-complete .steps-item)::before {        forced-color-adjust: none;        background: CanvasText;      }      /* As heavy as the line's own rules, the waiting one and the completed one, so neither keeps a theme color. */      &:not(:last-child)::after, &:is(:has(~ .steps-item[aria-current="step"]), .steps-complete .steps-item)::after {        background: CanvasText;      }    }  }  /* The words of a step: a title and an optional line under it. */  .steps-body {    display: grid;    gap: .0625rem;    min-width: 0;  }  /* One line, cut with an ellipsis where the step's room ends, so it never runs over the line to the next one. */  .steps-title {    min-width: 0;    margin: 0;    overflow: hidden;    font-weight: var(--font-weight-control);    text-overflow: ellipsis;    white-space: nowrap;  }  .steps-description {    margin: 0;    color: var(--color-text-muted);    font-size: .75rem;    font-weight: 400;    text-wrap: pretty;    overflow-wrap: anywhere;  }  /* Vertical: the marker stands on a column and the line runs down from it to the next marker. */  .steps-vertical .steps-item {    flex: none;    align-items: flex-start;    gap: .75rem;    padding-block-end: 1.25rem;    &:last-child {      padding-block-end: 0;    }    /* On the marker's middle, a half pixel back so the 1px line is centered as a timeline's and a trace's are. */    &:not(:last-child)::after {      position: absolute;      inset-block: calc(var(--steps-marker) + .25rem) .25rem;      inset-inline-start: calc(var(--steps-marker) / 2 - .5px);      flex: none;      width: 1px;      min-width: 0;      height: auto;    }  }  /* The first line stands on the middle of the marker, whether the title is alone or in a steps-body. */  .steps-vertical :is(.steps-body, .steps-item:not(:has(.steps-body)) .steps-title) {    padding-block-start: calc((var(--steps-marker) - 1lh) / 2);  }  .steps-vertical .steps-title {    white-space: normal;  }}