網站導覽

v2.1.0
網站頁面

置中版面

將單一任務放在檢視區中央,例如登入或錯誤頁面,可單獨呈現或搭配一側的面板。

置中版面將單一任務放在檢視區中央,例如登入、確認地址或顯示錯誤頁面。外框使用頁面,以 dvh 取得檢視區高度,再用兩個 utility 將內容置中。

置中版面

<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。 整頁只處理這項任務,因此直接在 <main> 上設定至少與檢視區等高的單欄版面。兩個置中用的 utility 會讓內容在水平與垂直方向上置中。p-lg 讓卡片在手機上與頁面邊緣保持距離。
  • 在卡片上設定 w-full max-w(380)。 卡片在手機上填滿可用寬度,並限制在適合單欄表單的最大寬度。
  • 面板下方使用托盤底色。 在外框上套用 bg-surface-tray,並用面板呈現卡片,讓卡片成為頁面上唯一凸起的表面。
  • 卡片比檢視區高時,頁面會捲動。 頁面必須能隨內容增高,因此只設定最小高度。手機開啟螢幕鍵盤時,就可能遇到這種情況。

卡片同時也是表單,由表單設定欄位之間的間距。

#搭配側面板

從 md 斷點起,外框分成等寬的兩欄,一欄呈現任務,另一欄放置品牌資訊、引文或圖片。低於這個斷點時,面板會隱藏,只留下任務。

搭配側面板

<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。文案請保持簡短,並將讀者需要的資訊放在其他地方,因為空間縮小時會優先隱藏面板。

#可以用它建構什麼

驗證流程和各種獨立存在的頁面,都是在這個外框中換上另一張卡片。

頁面卡片內容
登入、註冊登入區塊:它的第一張卡片,或註冊卡片
驗證同一個區塊的驗證碼卡片,圍繞著一次性驗證碼欄位
忘記密碼重設密碼區塊的兩張卡片
找不到頁面、錯誤、維護中空狀態區塊,說明發生了什麼事,並提供一條繼續前進的路

超過一個步驟的任務(例如設定工作區)有自己的頁面:多步驟任務。

#無障礙

  • 頁面只有一個 <h1>,放在卡片內。
  • 面板使用 <aside>。若只有裝飾,請用 aria-hidden="true" 將它從輔助技術隱藏。若含有引文,則應保留在可供輔助技術讀取的內容中。
  • 為欄位設定 autocomplete 值,讓密碼管理工具可以自動填寫。