다단계 작업은 몇 가지를 순서대로 묻습니다. 진행 상황이 사용자의 현재 위치를 알려 주고, 한 번에 한 단계만 진행하며, 그 단계의 버튼으로 다음으로 가거나 이전으로 돌아갑니다. 프레임은 페이지이므로 문서 전체가 함께 스크롤되고, 버튼은 폼의 흐름을 따라 폼 끝에 놓입니다. 예제는 세 단계로 워크스페이스를 설정하며, 입력한 내용을 페이지 자체의 메모리에 보관합니다.
다단계 작업
<div class="page bg-surface-base fg-text-body text-sm" data-example="multi-step"> <header class="navbar" style="--navbar-padding-x: max(1.5rem, calc(50% - 26rem))"> <a class="navbar-brand" href="#"> <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <circle cx="8" cy="8" r="6" /> <path d="M8 4.3333A3.6667 3.6667 0 0 1 8 11.6667Z" fill="currentColor" stroke="none" /> </svg>Atlas</a> <a class="btn btn-quiet btn-sm ml-auto shrink(1)" href="#">Save and exit</a> </header> <main class="grow(1) w-full max-w(880) mx-auto px-lg pt-xl pb-2xl container-inline"> <header class="flex flex-col gap-3xs mb-xl"> <h1 class="heading heading-xl">Set up your workspace</h1> <p class="m(0) fg-text-muted">Three steps, about two minutes. Everything here can be changed later in settings.</p> </header> <nav class="mb-xl max-w(560) hidden@container(--3xl)" aria-label="Progress"> <ol class="steps" data-ms-progress="short"> <li class="steps-item basis-auto"> <a class="steps-title link link-quiet" href="#ms-details">Basic details</a> </li> <li class="steps-item basis-auto"> <a class="steps-title link link-quiet" href="#ms-preferences">Preferences</a> </li> <li class="steps-item basis-auto"> <span class="steps-title">Review</span> </li> </ol> </nav> <div class="flex gap-2xl items-start"> <nav class="w(224) shrink(0) sticky top(72) hidden block@container(--3xl)" aria-label="Progress"> <ol class="steps steps-vertical" data-ms-progress> <li class="steps-item"> <span class="steps-body"> <a class="steps-title link link-quiet" href="#ms-details">Basic details</a> <span class="steps-description">Name, address and contact</span> </span> </li> <li class="steps-item"> <span class="steps-body"> <a class="steps-title link link-quiet" href="#ms-preferences">Preferences</a> <span class="steps-description">Alerts and region</span> </span> </li> <li class="steps-item"> <span class="steps-body"> <span class="steps-title">Review</span> <span class="steps-description">Check, then create</span> </span> </li> </ol> </nav> <div class="grow(1) basis(0) min-w(0) max-w(560)"> <div data-ms-task> <form class="form" method="post"> <section id="ms-details" data-ms-step aria-labelledby="ms-details-title"> <div class="form-fields"> <div class="flex flex-col gap-3xs"> <h2 class="heading scroll-mt(72)" id="ms-details-title" tabindex="-1"> <span class="sr-only">Step 1 of 3:</span>Basic details</h2> <p class="m(0) fg-text-muted">What the workspace is called and who answers for it.</p> </div> <div class="field"> <label for="ms-name">Workspace name</label> <input class="input" id="ms-name" name="name" autocomplete="organization" required pattern=".*\S.*" data-error="ms-name-error"> <span class="field-error" id="ms-name-error">Enter a name for the workspace.</span> </div> <div class="field"> <label for="ms-slug">Address</label> <div class="input-group"> <span class="input-group-addon">atlas.dev/</span> <input class="input-group-field" id="ms-slug" name="slug" autocomplete="off" autocapitalize="none" spellcheck="false" pattern="[a-z0-9]+(-[a-z0-9]+)*" required aria-describedby="ms-slug-hint" data-error="ms-slug-error"> </div> <span class="field-hint" id="ms-slug-hint">Lowercase letters, numbers and hyphens.</span> <span class="field-error" id="ms-slug-error">Enter an address in lowercase letters, numbers and hyphens, such as atlas-labs.</span> </div> <div class="field"> <label for="ms-email">Contact email</label> <input class="input" id="ms-email" type="email" name="email" autocomplete="email" placeholder="you@company.com" required data-error="ms-email-error"> <span class="field-error" id="ms-email-error">Enter an email address, such as you@company.com.</span> </div> </div> </section> <section id="ms-preferences" data-ms-step aria-labelledby="ms-preferences-title"> <div class="form-fields"> <div class="flex flex-col gap-3xs"> <h2 class="heading scroll-mt(72)" id="ms-preferences-title" tabindex="-1"> <span class="sr-only">Step 2 of 3:</span>Preferences</h2> <p class="m(0) fg-text-muted">How Atlas reaches you, and where it builds.</p> </div> <fieldset class="fieldset gap-sm"> <legend class="fieldset-legend">Where should deployment alerts go?</legend> <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 11rem"> <label class="choice"> <input type="radio" class="radio" name="alerts" value="email" checked> <span class="choice-body"> <span class="choice-title">Email</span> <span class="choice-description">To the contact address, as each deployment fails.</span> </span> </label> <label class="choice"> <input type="radio" class="radio" name="alerts" value="phone"> <span class="choice-body"> <span class="choice-title">Phone</span> <span class="choice-description">A text message, for production only.</span> </span> </label> <label class="choice"> <input type="radio" class="radio" name="alerts" value="none"> <span class="choice-body"> <span class="choice-title">None</span> <span class="choice-description">Nothing is sent. Failures show in the dashboard.</span> </span> </label> </div> </fieldset> <div data-ms-phone> <div class="field"> <label for="ms-phone">Phone number</label> <input class="input" id="ms-phone" type="tel" name="phone" autocomplete="tel" pattern="\+?[0-9][0-9 \-]{6,}" aria-describedby="ms-phone-hint" data-error="ms-phone-error"> <span class="field-hint" id="ms-phone-hint">Needed only when alerts go to a phone. Include the country code.</span> <span class="field-error" id="ms-phone-error">Enter a phone number with its country code, such as +886 912 345 678.</span> </div> </div> <div class="field"> <label for="ms-region">Default region</label> <select class="select" id="ms-region" name="region" aria-describedby="ms-region-hint"> <option class="select-option" value="Tokyo (hnd1)">Tokyo (hnd1)</option> <option class="select-option" value="Singapore (sin1)">Singapore (sin1)</option> <option class="select-option" value="Frankfurt (fra1)">Frankfurt (fra1)</option> <option class="select-option" value="Washington, D.C. (iad1)">Washington, D.C. (iad1)</option> </select> <span class="field-hint" id="ms-region-hint">Where new projects are built and served.</span> </div> </div> </section> <section id="ms-review" data-ms-step data-ms-review aria-labelledby="ms-review-title" hidden> <div class="form-fields"> <div class="flex flex-col gap-3xs"> <h2 class="heading scroll-mt(72)" id="ms-review-title" tabindex="-1"> <span class="sr-only">Step 3 of 3:</span>Review</h2> <p class="m(0) fg-text-muted">Check what you entered, then create the workspace.</p> </div> <div class="flex flex-col gap-2xs"> <div class="flex items-center justify-between gap-sm"> <h3 class="heading heading-xs">Basic details</h3> <button type="button" class="btn btn-quiet btn-sm btn-hang-end" data-ms-edit="0">Edit <span class="sr-only">basic details</span> </button> </div> <dl class="data-list"> <div class="data-list-item"> <dt class="data-list-term min-w(128)">Workspace name</dt> <dd class="data-list-value" data-ms-value="name"></dd> </div> <div class="data-list-item"> <dt class="data-list-term">Address</dt> <dd class="data-list-value" data-ms-value="address"></dd> </div> <div class="data-list-item"> <dt class="data-list-term">Contact email</dt> <dd class="data-list-value" data-ms-value="email"></dd> </div> </dl> </div> <div class="flex flex-col gap-2xs"> <div class="flex items-center justify-between gap-sm"> <h3 class="heading heading-xs">Preferences</h3> <button type="button" class="btn btn-quiet btn-sm btn-hang-end" data-ms-edit="1">Edit <span class="sr-only">preferences</span> </button> </div> <dl class="data-list"> <div class="data-list-item"> <dt class="data-list-term min-w(128)">Deployment alerts</dt> <dd class="data-list-value" data-ms-value="alerts"></dd> </div> <div class="data-list-item"> <dt class="data-list-term">Default region</dt> <dd class="data-list-value" data-ms-value="region"></dd> </div> </dl> </div> </div> </section> <div class="form-actions"> <button type="button" class="btn hidden" data-ms-back>Back</button> <button class="btn btn-primary" data-ms-next>Create workspace</button> </div> </form> </div> <div data-ms-done hidden> <div class="flex flex-col items-start gap-md"> <span class="icon-frame icon-frame-success" aria-hidden="true"> <svg class="icon" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M3.5 10L7.8545 14.3545A0.2 0.2 0 0 0 8.1413 14.3504L16.5 5.5" /> </svg> </span> <div class="flex flex-col gap-3xs"> <h2 class="heading scroll-mt(72)" tabindex="-1" data-ms-done-title>Workspace created</h2> <p class="m(0) fg-text-muted"> <span class="fg-text-strong" data-ms-value="name"></span>is ready at <span class="fg-text-strong" data-ms-value="address"></span>. This example keeps what you typed in memory only: nothing was sent.</p> </div> <button type="button" class="btn" data-ms-restart>Start over</button> </div> </div> </div> </div> </main></div>/** * A workspace set up in three steps, with nowhere to send it. The markup is one whole form in order, which is * what a browser without this module shows. The module divides it: it shows one step at a time, moves * aria-current along the progress, checks the step in hand before going on, and at the end swaps the form * for the result. What was typed stays in the fields, and where the reader is stays in `state`; nothing is * stored and nothing leaves the page. In a product each step is a route and the server keeps the draft. * Returns the function that stops it and puts the whole form back. */export function mount(root) { const controller = new AbortController() const { signal } = controller const task = root.querySelector('[data-ms-task]') const form = task.querySelector('.form') const steps = [...form.querySelectorAll('[data-ms-step]')] const review = form.querySelector('[data-ms-review]') const back = form.querySelector('[data-ms-back]') const next = form.querySelector('[data-ms-next]') const done = root.querySelector('[data-ms-done]') const phone = form.querySelector('[data-ms-phone]') // The same three steps twice: the vertical list of a wide page and the short row of a narrow one. const lists = [...root.querySelectorAll('[data-ms-progress]')].map(list => ({ list, short: list.dataset.msProgress === 'short', items: [...list.querySelectorAll('.steps-item')] })) const last = steps.length - 1 const submitLabel = next.textContent // Where the reader is, the furthest step they have reached, and whether the task is finished. const state = { step: 0, reached: 0, done: false } /** * A step's name in the progress is a link while the step can be opened and plain words while it cannot, as * the steps component asks: the element is replaced only when that changes. */ const name = (item, index, open) => { const old = item.querySelector('.steps-title') if ((old.localName === 'a') === open) return old const title = document.createElement(open ? 'a' : 'span') title.className = open ? 'steps-title link link-quiet' : 'steps-title' title.textContent = old.textContent if (open) title.href = `#${steps[index].id}` old.replaceWith(title) return title } const headingOf = (step) => steps[step].querySelector('.heading') const controlsOf = (step) => [...steps[step].querySelectorAll('input, select, textarea')].filter(control => control.willValidate) /** * A field's error is read with the field only while it shows: its id joins aria-describedby, after the hint, * while the field is marked or the browser reports it, and leaves when the value is valid again. */ const describe = (control) => { if (!control.dataset?.error) return const invalid = !control.validity.valid && (control.getAttribute('aria-invalid') === 'true' || control.matches(':user-invalid')) if (control.validity.valid) control.removeAttribute('aria-invalid') const ids = (control.getAttribute('aria-describedby') ?? '').split(' ').filter(id => id && id !== control.dataset.error) if (invalid) ids.push(control.dataset.error) if (ids.length) control.setAttribute('aria-describedby', ids.join(' ')) else control.removeAttribute('aria-describedby') } /** * The browser holds the rules (required, type, pattern) and shows a field's error once the reader has edited * it. A field never touched has to be marked here, with aria-invalid, when Next is pressed: a submit would mark * every field of the form as tried, the ones in steps not reached yet among them. Focus goes to the first. */ const check = (step) => { const invalid = controlsOf(step).filter(control => !control.validity.valid) for (const control of invalid) { control.setAttribute('aria-invalid', 'true') describe(control) } if (!invalid.length) return true if (state.step !== step) { state.step = step render() } invalid[0].focus() return false } // The phone number is asked for, and required, only while alerts go to a phone. const askPhone = () => { const field = phone.querySelector('.input') const wanted = form.elements.alerts.value === 'phone' phone.hidden = !wanted field.disabled = !wanted field.required = wanted if (!wanted) field.removeAttribute('aria-invalid') // An error that no longer shows is no longer read with the field when it comes back. describe(field) } const values = () => { const written = new FormData(form) const text = (name) => String(written.get(name) ?? '').trim() const alerts = { email: `Email to ${text('email')}`, phone: `Text message to ${text('phone')}`, none: 'None' } return { name: text('name'), address: `atlas.dev/${text('slug')}`, email: text('email'), alerts: alerts[text('alerts')], region: text('region') } } const render = () => { task.hidden = state.done done.hidden = !state.done steps.forEach((step, index) => { step.hidden = index !== state.step }) // A button's own display outranks the hidden attribute, so Back leaves with the utility of that name. back.classList.toggle('hidden', state.step === 0) next.textContent = state.step === last ? submitLabel : 'Next' for (const { list, short, items } of lists) { list.classList.toggle('steps-complete', state.done) items.forEach((item, index) => { const current = !state.done && index === state.step // A step already reached is a link back to it; the current one and the ones ahead are plain words. const open = !state.done && !current && index <= state.reached if (current) item.setAttribute('aria-current', 'step') else item.removeAttribute('aria-current') // In the short row the other steps' names are not drawn, and a link nobody can see is not one to tab to or // to tap: there a step already reached is words, and Back is the way to it. const title = name(item, index, open && !short) // The short row shows the current step's name; the others keep theirs for assistive technology. if (short) title.classList.toggle('sr-only', !current) }) } // What was typed is set as text, never as markup. if (state.done || state.step === last) { const written = values() for (const slot of root.querySelectorAll('[data-ms-value]')) slot.textContent = written[slot.dataset.msValue] } } /** * Going on checks every step passed on the way and stops at the first that fails. Going back checks nothing: * a reader may leave a step half written and find it as they left it. */ const go = (target) => { for (let step = state.step; step < target; step++) if (!check(step)) return state.step = target state.reached = Math.max(state.reached, target) render() headingOf(target).focus() } const advance = () => { if (state.step < last) return go(state.step + 1) for (let step = 0; step < last; step++) if (!check(step)) return state.done = true render() done.querySelector('[data-ms-done-title]').focus() } next.addEventListener('click', advance, { signal }) back.addEventListener('click', () => go(state.step - 1), { signal }) // Next is not a submit button, so Enter in a field is given the same meaning here. form.addEventListener('keydown', (event) => { if (event.key !== 'Enter' || event.isComposing || !event.target.matches('input')) return event.preventDefault() advance() }, { signal }) form.addEventListener('submit', event => event.preventDefault(), { signal }) for (const type of ['input', 'change', 'focusout']) { form.addEventListener(type, event => describe(event.target), { signal }) } form.addEventListener('change', (event) => { if (event.target.name === 'alerts') askPhone() }, { signal }) // A step already reached is opened from the progress, and from Edit in the review. for (const { list, items } of lists) { list.addEventListener('click', (event) => { const title = event.target.closest('a.steps-title') if (!title) return event.preventDefault() go(items.indexOf(title.closest('.steps-item'))) }, { signal }) } for (const edit of form.querySelectorAll('[data-ms-edit]')) { edit.addEventListener('click', () => go(Number(edit.dataset.msEdit)), { signal }) } const clear = () => { form.reset() for (const control of form.querySelectorAll('[data-error]')) { control.removeAttribute('aria-invalid') describe(control) } Object.assign(state, { step: 0, reached: 0, done: false }) } root.querySelector('[data-ms-restart]').addEventListener('click', () => { clear() askPhone() render() headingOf(0).focus() }, { signal }) next.type = 'button' askPhone() render() return () => { controller.abort() clear() // The whole form again, in order, as the markup has it. task.hidden = false done.hidden = true steps.forEach((step) => { step.hidden = step === review }) back.classList.add('hidden') next.type = 'submit' next.textContent = submitLabel phone.hidden = false phone.querySelector('.input').disabled = false phone.querySelector('.input').required = false for (const { list, items } of lists) { list.classList.remove('steps-complete') items.forEach((item, index) => { item.removeAttribute('aria-current') // The review holds no field, so the whole form has nothing to link its step to. name(item, index, steps[index] !== review).classList.remove('sr-only') }) } }}#구성 방법
- 작업용 헤더가 있는 페이지. 내비게이션 바에는 브랜드와 나가는 길 하나만 있습니다.
ml-auto로 맨 끝에 밀어 둔, 강조를 줄인 "Save and exit"입니다. 작업 페이지에는 주 내비게이션이 없습니다. 다른 링크는 모두 작업한 내용을 잃게 만드는 길이기 때문입니다. - 작업을 위한 하나의 너비 제한. 메인 영역은
max-w(880) mx-auto px-lg이며 크기 컨테이너인container-inline입니다. 그러면 832px이 남습니다.w(224)인 진행 상황 열, 48px인gap-2xl, 그리고max-w(560)인 폼이 들어가며, 560px은 필드 한 열을 읽기 좋은 최대 너비입니다. - 진행 상황에는 단계. 현재 항목에만
aria-current="step"이 있으며, 스타일시트가 그 앞의 단계는 완료로, 뒤의 단계는 대기로 그립니다. 열 수 있는 단계의 이름은 강조를 줄인 링크이고, 나머지는 일반 텍스트입니다. - 작업 전체에 폼 하나. 각 단계는 제목으로 이름을 지정한
<section>이며 필드를form-fields에 담으므로, 폼의 간격인 1.25rem이 유지됩니다. 두 번째 단계의 옵션은 선택 카드 블록입니다. legend가 질문인<fieldset>과, 선택 옵션을 담은 자동 그리드로 이루어지며, 선택 옵션은 폼의 열에서는 세 개가 나란히, 휴대폰에서는 위아래로 놓입니다. - 폼 끝에
form-actions. 소스에서는 Back이 먼저, 확인 버튼이 마지막에 옵니다. 폼의 너비가 24rem 미만이면 두 버튼이 전체 너비로 쌓이고 확인 버튼이 먼저 옵니다. 휴대폰이 여기에 해당합니다. 뷰포트 하단에 고정하는 것은 없습니다. 하단에 고정한 바는 키보드가 열리면 그 위의 필드를 가립니다. - 검토 단계는 단계마다 데이터 목록 하나입니다. 단계의 이름과 그 단계를 여는 Edit 버튼 아래에 놓입니다. 이 버튼은 강조를 줄인 버튼이며
btn-hang-end를 적용하므로, 버튼의 글자가 값이 닿는 가장자리에서 끝납니다.
#너비별 진행 상황
페이지에는 진행 상황이 두 번 들어 있고, 그중 하나만 표시합니다.
- 메인 영역의 너비가 48rem 이상이면 폼 옆의
steps steps-vertical목록입니다. 각 단계에 이름과, 무엇을 묻는지 설명하는 한 줄이 있습니다. 목록은sticky top(72)로 56px 높이의 내비게이션 바에서 16px 아래에 붙으므로, 긴 단계를 스크롤하는 동안에도 화면에 남습니다. - 48rem 미만이면 폼 위의
steps한 줄입니다. 이 줄에는 현재 단계의 이름만 표시되고, 나머지 두 단계의 이름은sr-only입니다. 따라서 표식과 선이 위치를 나타내고, 모든 이름은 여전히 스크린 리더로 읽힙니다.
줄에는 hidden@container(--3xl)이, 열에는 hidden block@container(--3xl)이 있습니다. 표시되지 않는 쪽은 display: none이므로 보조 기술과 키보드는 진행 상황을 하나만 만납니다.
세 이름을 모두 표시한 단계 줄은 휴대폰에 들어가지 않습니다. 컴포넌트는 공간이 없는 이름을 말줄임표로 자릅니다. 이름이 하나면 390px에서도 줄 전체가 온전히 표시됩니다. 줄의 각 항목은 basis-auto이므로 현재 단계는 이름에 필요한 만큼의 공간을 차지하고 나머지 둘이 남은 공간을 나눕니다. 텍스트 크기를 두 배로 키운 휴대폰에서는 그 이름 하나마저 잘리지만, 줄 아래의 제목이 이름을 온전히 알려 줍니다.
#스크립트가 결정하는 것
마크업은 순서대로 작성한 폼 전체입니다. 필드가 있는 두 단계가 이어지고, 폼을 전송하는 버튼 하나가 옵니다. 이를 단계로 나누는 것은 예제의 모듈이며, 브라우저와 스타일시트가 대부분의 일을 하므로 모듈은 짧습니다.
- 규칙은 브라우저가 가집니다.
required,type="email",pattern이 유효한 값이 무엇인지 정하고, 모듈은validity.valid만 읽습니다. 각 필드의 메시지는field-error에 있으며, 입력 필드 스타일시트가 필드가 유효하지 않은 동안 이를 표시하고 유효해지면 다시 숨깁니다. :user-invalid는 사용자가 필드를 편집한 뒤에 오류를 표시합니다. 여기에는 스크립트가 필요 없습니다. 한 번도 건드리지 않은 필드는 사정이 다릅니다. Next는 해당 단계에서 검증에 실패한 모든 필드에aria-invalid="true"를 설정해 같은 상태를 그리고, 각 값이 유효해지면 이를 제거합니다.- Next는 제출 버튼이 아니라 일반 버튼입니다. 제출을 시도하면 폼의 모든 필드가 시도된 것으로 표시되는데, 여기에는 아직 도달하지 않은 단계의 필드도 포함되므로 그 단계는 처음부터 오류 상태로 열리게 됩니다. 그래서 모듈이 진행 중인 단계를 직접 검사하고, 필드에서 누르는 Enter 키에 Next와 같은 의미를 부여합니다.
- 포커스는 사용자를 따라갑니다. 단계가 검증에 실패하면 포커스는 유효하지 않은 첫 번째 필드로 이동합니다. 단계가 바뀌면 포커스는 새 단계의 제목으로 이동하며, 제목은 "Step 2 of 3: Preferences"처럼 단계와 그 위치를 알려 줍니다.
- 뒤로 갈 때는 아무것도 검사하지 않습니다. Back, 진행 상황의 단계 이름, 검토 단계의 Edit은 모두 현재 단계를 작성하다 만 상태까지 그대로 두며, 모든 필드는 문서를 떠나지 않으므로 값을 유지합니다. 앞으로 갈 때는 거쳐 가는 단계를 하나씩 검사하고, 처음으로 실패한 단계에서 멈춥니다. 아직 도달하지 않은 단계는 링크가 아니므로 건너뛰어 갈 수 없습니다.
- 답에 따라 달라지는 필드. 전화번호 필드는 알림을 휴대폰으로 받도록 선택한 동안에만 표시되고 필수가 됩니다. 표시되지 않는 동안에는
disabled이므로 검사하지도 전송하지도 않습니다.
제품에서는 이 가운데 대부분을 라우터와 서버가 담당합니다.
- 단계마다 경로 하나. 예를 들어
/setup/details와/setup/preferences입니다. 그러면 각 단계가 독립된 폼이 되고, Next는 그 폼의 제출 버튼이 되며, 브라우저의 뒤로 가기와 새로 고침이 사용자의 기대대로 동작합니다. 진행 상황의 링크는 그 경로로 가는 실제 링크가 됩니다. - 서버는 모든 단계를 다시 검증하고 찾은 오류와 함께 응답합니다. 오류는 같은 방식으로 표시하세요. 필드에
aria-invalid="true"를 설정하고 메시지를 해당field-error에 넣습니다. - 초안은 서버가 보관합니다. Next를 누를 때마다 그 단계의 내용을 저장하고, "Save and exit"는 저장한 뒤 나가며, 검토 단계는 필드 대신 초안을 읽어 옵니다. 도달한 가장 먼 단계도 초안의 일부이며, 서버는 그보다 뒤의 경로를 거부합니다.
#사용 시점
순서가 중요할 때 단계를 사용하세요. 뒤 단계가 앞의 답에 따라 달라지거나, 전체를 한 번에 받아들이기에는 너무 많은 경우입니다. 단계 수는 세 개에서 다섯 개가 적당합니다. 그보다 많다면 일부를 작업이 끝난 뒤로 미룰 수 있는지 살펴보세요.
- 그룹이 서로 독립적이고 사용자가 다시 돌아와 그중 하나를 바꾸는 경우에는 설정 페이지를 사용하세요. 설정 페이지의 내비게이션으로는 어떤 그룹이든 원하는 순서로 열 수 있습니다.
- 모든 것이 한 화면에 들어간다면 폼 하나를 사용하세요. 단계를 나누면 사용자는 전체를 한눈에 볼 수 없고, 부분마다 버튼을 한 번씩 더 눌러야 합니다.
- 로그인처럼 앞뒤에 다른 것이 없는 짧은 작업 하나에는 가운데 정렬 페이지를 사용하세요.
#접근성
- 랜드마크는 헤더, 메인 영역, 그리고 이름이 "Progress"인 내비게이션 하나입니다. 진행 중인 단계는 제목으로 이름을 지정한
<section>입니다. - 진행 상황은
<ol>이므로 목록이 단계가 몇 개인지 알려 주고, 현재 단계에는aria-current="step"이 있습니다. 짧은 줄에서 표시되지 않는 이름도 목록에는 그대로 있습니다. - 단계가 바뀐 뒤 포커스는 그 단계의 제목에 있습니다. 제목에는
tabindex="-1"과scroll-mt(72)가 있어 상단에 붙는 내비게이션 바에 가려지지 않습니다. 스크린 리더는 거기서 단계의 위치와 이름을 읽고, Tab 키를 누르면 첫 번째 필드로 이동합니다. - 단계가 검증에 실패하면 포커스는 유효하지 않은 첫 번째 필드에 있습니다. 필드의
field-error는 표시되는 동안aria-describedby에 추가되므로 메시지가 레이블과 함께 읽힙니다. - 마지막에는 포커스가 결과의 제목으로 이동하고, "Start over"는 필드를 비우고 첫 번째 단계의 제목으로 돌아갑니다.
- 스크립트가 없으면 페이지는 하나의 긴 폼입니다. 필드가 있는 두 단계가 모두 마크업에 있고 어느 것도
hidden이 아니며, 전화번호 필드는 언제 필요한지 설명하고, 버튼은 모든 것을 한 번에 전송합니다. 필드가 없는 Back, 검토, 결과만 숨겨진 상태로 시작합니다.
#관련 항목
- 단계결제나 초기 설정처럼 짧은 절차에서 현재 위치를 번호 목록으로 표시합니다.
- 폼열 너비에 맞춰 행, 섹션, 동작 버튼을 배치하는 폼 레이아웃입니다.
- 입력 필드표면을 파낸 듯한 텍스트 입력 필드와 레이블, 힌트, 오류, 입력 그룹.
- 선택 옵션선택지에 관한 설명을 담을 만큼 넉넉한 라디오 버튼 또는 체크박스 옵션입니다.
- 라디오 버튼여러 선택지 중 하나를 고르는 작고 둥근 버튼으로, 네이티브 라디오 입력에 적용합니다.
- 셀렉트인터페이스의 다른 부분과 같은 표면 스타일로 옵션 목록을 표시하는 네이티브 셀렉트입니다.
- 자동 그리드그리드가 주어진 공간에 들어갈 수 있는 같은 너비의 열 수를 직접 정합니다.
- 데이터 목록배포, 주문, 프로필처럼 한 대상의 정보를 가는 선으로 나눈 항목 이름과 값으로 보여 줍니다.
- 내비게이션 바스크롤하는 콘텐츠가 막대 아래를 지나갈 때 표면 효과가 나타나는 페이지 상단의 막대입니다.
- 버튼표면 위로 살짝 돌출되어 있으며, 포인터를 올리면 떠오르고 누르면 가라앉는 버튼입니다.
- 링크문장 속에서 주변 텍스트와 같은 색으로 표시되며 다른 위치로 이동하는 텍스트입니다.
- 제목페이지의 기본 글자색으로 표시하는 제목과 제목 위 안내 문구, 아래 소개 문단입니다.
- 아이콘 프레임제목 옆에 아이콘을 크기에 맞게 담는 작은 오목한 영역입니다.