中央配置レイアウトは、ログイン、アドレスの確認、エラーページなど、1つの用途に絞った画面をビューポートの中央に配置します。外枠にはページを使い、dvhでビューポートの高さを確保します。中身は2つのユーティリティで中央に揃えます。
中央配置
<main class="page items-center justify-center p-lg bg-surface-tray fg-text-body text-sm"> <form class="sheet form w-full max-w(380) p-xl"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form></main><main className="page items-center justify-center p-lg bg-surface-tray fg-text-body text-sm"> <form className="sheet form w-full max-w(380) p-xl"> <header className="flex flex-col gap-3xs"> <h1 className="heading heading-lg">Sign in to Atlas</h1> <p className="m(0) fg-text-muted">Welcome back.</p> </header> <label className="field"> Email<input className="input" type="email" name="email" autoComplete="username" placeholder="you@example.com" required /> </label> <label className="field"> Password<input className="input" type="password" name="password" autoComplete="current-password" required /> </label> <button className="btn btn-primary">Sign in</button> <p className="m(0) text-center fg-text-muted"> New here? <a className="link" href="#">Create an account</a> </p> </form></main><main class="page items-center justify-center p-lg bg-surface-tray fg-text-body text-sm"> <form class="sheet form w-full max-w(380) p-xl"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form></main><template> <main class="page items-center justify-center p-lg bg-surface-tray fg-text-body text-sm"> <form class="sheet form w-full max-w(380) p-xl"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form> </main></template>#構成
page items-center justify-center。 1つのタスクでページ全体を使うため、<main>自体を、少なくともビューポートと同じ高さの縦方向レイアウトにします。2つのユーティリティで中身を縦横とも中央に揃えます。p-lgで、スマートフォンでもカードが画面の端に接しないようにします。- カードに
w-full max-w(380)。 スマートフォンでは利用可能な幅いっぱいに広がり、広い画面では入力欄を1列に並べるのに適した幅に収まります。 - トレイに載せたシート。 外枠に
bg-surface-trayを指定し、カードにはシートを使います。ページ上でカードだけが一段高く見えます。 - カードがビューポートより高くなると、ページがスクロールします。 最小の高さだけを指定し、カードに合わせてページが伸びるようにしているためです。たとえば、スマートフォンでキーボードを開いたときにこの状態になります。
カードはフォームも兼ねており、入力欄どうしの間隔はフォームのスタイルで決まります。
#パネル付き
mdブレークポイント以上では、外枠を等幅の2カラムに分けます。一方にタスクを配置し、もう一方にはブランド表示、引用文、画像などを載せるパネルを置きます。それ未満ではパネルが非表示になり、タスクだけが残ります。
パネル付き
<div class="page bg-surface-base fg-text-body text-sm"> <div class="grow(1) grid grid-cols(2)@md"> <main class="flex items-center justify-center p-lg"> <form class="form w-full max-w(340)"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form> </main> <aside class="hidden flex@md flex-col justify-between p-2xl bg-surface-inverse fg-text-inverse"> <p class="m(0) flex items-center gap-xs text-md font-medium"> <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 </p> <figure class="m(0) flex flex-col gap-md max-w(440)"> <blockquote class="m(0)"> <p class="m(0) text-2xl"> We replaced four libraries with a stylesheet, and the interface got quieter. </p> </blockquote> <figcaption class="flex items-center gap-sm text-sm"> <span class="avatar" aria-hidden="true"> <img class="avatar-image" src="/demo/people/seoyeon-kim.webp" alt width="32" height="32"><span class="avatar-fallback">SK</span> </span>Seo-yeon Kim, Engineering at Orbit </figcaption> </figure> </aside> </div></div>import ContrastIcon from '@master/icons-react/native/16/soft/contrast'<div className="page bg-surface-base fg-text-body text-sm"> <div className="grow(1) grid grid-cols(2)@md"> <main className="flex items-center justify-center p-lg"> <form className="form w-full max-w(340)"> <header className="flex flex-col gap-3xs"> <h1 className="heading heading-lg">Sign in to Atlas</h1> <p className="m(0) fg-text-muted">Welcome back.</p> </header> <label className="field"> Email<input className="input" type="email" name="email" autoComplete="username" placeholder="you@example.com" required /> </label> <label className="field"> Password<input className="input" type="password" name="password" autoComplete="current-password" required /> </label> <button className="btn btn-primary">Sign in</button> <p className="m(0) text-center fg-text-muted"> New here? <a className="link" href="#">Create an account</a> </p> </form> </main> <aside className="hidden flex@md flex-col justify-between p-2xl bg-surface-inverse fg-text-inverse"> <p className="m(0) flex items-center gap-xs text-md font-medium"> <ContrastIcon className="icon" />Atlas </p> <figure className="m(0) flex flex-col gap-md max-w(440)"> <blockquote className="m(0)"> <p className="m(0) text-2xl"> We replaced four libraries with a stylesheet, and the interface got quieter. </p> </blockquote> <figcaption className="flex items-center gap-sm text-sm"> <span className="avatar" aria-hidden="true"> <img className="avatar-image" src="/demo/people/seoyeon-kim.webp" alt="" width="32" height="32" /><span className="avatar-fallback">SK</span> </span>Seo-yeon Kim, Engineering at Orbit </figcaption> </figure> </aside> </div></div><script> import ContrastIcon from '@master/icons-svelte/native/16/soft/contrast'</script><div class="page bg-surface-base fg-text-body text-sm"> <div class="grow(1) grid grid-cols(2)@md"> <main class="flex items-center justify-center p-lg"> <form class="form w-full max-w(340)"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form> </main> <aside class="hidden flex@md flex-col justify-between p-2xl bg-surface-inverse fg-text-inverse"> <p class="m(0) flex items-center gap-xs text-md font-medium"> <ContrastIcon class="icon" />Atlas </p> <figure class="m(0) flex flex-col gap-md max-w(440)"> <blockquote class="m(0)"> <p class="m(0) text-2xl"> We replaced four libraries with a stylesheet, and the interface got quieter. </p> </blockquote> <figcaption class="flex items-center gap-sm text-sm"> <span class="avatar" aria-hidden="true"> <img class="avatar-image" src="/demo/people/seoyeon-kim.webp" alt width="32" height="32"><span class="avatar-fallback">SK</span> </span>Seo-yeon Kim, Engineering at Orbit </figcaption> </figure> </aside> </div></div><script setup>import ContrastIcon from '@master/icons-vue/native/16/soft/contrast'</script><template> <div class="page bg-surface-base fg-text-body text-sm"> <div class="grow(1) grid grid-cols(2)@md"> <main class="flex items-center justify-center p-lg"> <form class="form w-full max-w(340)"> <header class="flex flex-col gap-3xs"> <h1 class="heading heading-lg">Sign in to Atlas</h1> <p class="m(0) fg-text-muted">Welcome back.</p> </header> <label class="field"> Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required> </label> <label class="field"> Password<input class="input" type="password" name="password" autocomplete="current-password" required> </label> <button class="btn btn-primary">Sign in</button> <p class="m(0) text-center fg-text-muted"> New here? <a class="link" href="#">Create an account</a> </p> </form> </main> <aside class="hidden flex@md flex-col justify-between p-2xl bg-surface-inverse fg-text-inverse"> <p class="m(0) flex items-center gap-xs text-md font-medium"> <ContrastIcon class="icon" />Atlas </p> <figure class="m(0) flex flex-col gap-md max-w(440)"> <blockquote class="m(0)"> <p class="m(0) text-2xl"> We replaced four libraries with a stylesheet, and the interface got quieter. </p> </blockquote> <figcaption class="flex items-center gap-sm text-sm"> <span class="avatar" aria-hidden="true"> <img class="avatar-image" src="/demo/people/seoyeon-kim.webp" alt width="32" height="32"><span class="avatar-fallback">SK</span> </span>Seo-yeon Kim, Engineering at Orbit </figcaption> </figure> </aside> </div> </div></template>「タブレット」と「スマートフォン」ではパネルが非表示になり、フォームだけが表示されます。
grid grid-cols(2)@mdで外枠を分割し、パネルにはhidden flex@mdを指定します。外枠がビューポートと一致するため、コンテナー幅による判定は不要です。ここでは@mdでビューポートの幅を判定します。
パネルはインク面とし、背景にbg-surface-inverse、文字色にfg-text-inverseを指定します。パネルは幅が狭くなると最初に非表示になるため、文言は短くし、読者に必要な情報は別の場所に置きます。
#このフレームで作るページ
認証のページと、単独で成り立つページは、どれもこのフレームに別のカードを入れたものです。
| ページ | カードの中身 |
|---|---|
| ログイン、アカウント登録 | ログインブロックの最初のカード、またはアカウント登録 |
| 確認 | 同じブロックのコードのカード。ワンタイムコードを囲みます |
| パスワードを忘れた場合 | パスワードの再設定ブロックの2つのカード |
| ページが見つからない、エラー、メンテナンス | 何が起きたかを伝え、先へ進む手段を1つ示す空の状態ブロック |
ワークスペースの設定のように、ステップが複数あるタスクには専用のページがあります。複数ステップのタスクです。
#アクセシビリティ
- ページ内の
<h1>は、カード内の1つだけです。 - パネルには
<aside>を使います。装飾だけを載せる場合は、aria-hidden="true"で支援技術から隠します。引用文を載せる場合は、コンテンツとして支援技術にも公開します。 - パスワードマネージャーで自動入力できるよう、入力欄に
autocompleteの値を指定します。
#関連項目
- フォームフォームの幅に応じて行、セクション、操作ボタンを配置するレイアウト。
- サーフェストレイ、シート、ウェル。すべてのコンポーネントの土台となる、奥行きの異なる素材です。
- 入力フィールド背景面より一段くぼんだテキスト入力フィールド。ラベル、ヒント、エラー、グループに対応します。
- ボタン面からわずかに浮いた操作要素です。ポインターを重ねるとさらに浮き上がり、押すと沈み込みます。
- リンク周囲の文と同じ文字色で表示する、移動先を持つテキストリンク。