ナビゲーション
ステップ
購入手続きや初期設定のような短い手順の中での現在位置を、番号付きリストで示します。
このページの内容
ステップは、購入手続きや初期設定など、短い手順の中での現在位置を示します。順序付きリストを使い、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>#1 つの属性
1 つの属性で 3 つの状態が決まります。
- 現在のステップには
aria-current="step"を付けます。マーカーは小さなシートのように浮き上がり、インク色の輪郭が付きます。 - 現在のステップより前のステップは完了です。判定には
.steps-item:has(~ .steps-item[aria-current="step"])を使います。マーカーはインク色の円からチェックマークを抜いた形です。チェック部分には下のサーフェスが透けるため、どちらのテーマでも見分けられます。次のステップへ伸びる線もインク色になります。 - 残りのステップは未着手で、ウェルの中に番号を表示します。
属性を次の項目に移すと、3 つの状態がすべて更新されます。手順全体が終わると現在のステップはなくなります。リストに 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 | ステップを縦に並べる配置。狭い列や、各ステップに1文ずつ添える場合に使用steps と併用します |
steps-complete | 全ステップが完了し、進行中のステップがない状態steps と併用します |
steps-item | li に適用するステップです。待機中はくぼみの中に番号を表示します。現在のステップより前にある場合は、前景色の円にチェックマークを表示します。 |
steps-body | タイトルと説明の両方があるステップで、それらをまとめて囲みます。 |
steps-title | ステップ名は 1 行で表示し、縦並びのリストでは折り返します。 |
steps-description | タイトルの下に置く控えめな 1 行 |
#カスタムプロパティ
| プロパティ | 既定値 | 説明 |
|---|---|---|
--steps-marker | 1.5rem | マーカーの直径 |