ナビゲーション

v2.1.0
アプリケーションのブロック

ログイン

外部サービスでの認証、入力欄、画面切り替えリンクを備えたログイン・アカウント登録カード。

ログインは、どのプロダクトにもある画面です。このブロックは、見出し、すぐにログインできる手段、区切り線、入力欄、もう一方のカードへのリンクを1枚のカードにまとめます。シートがフォームを兼ねるため、入力欄は一定の間隔で縦に並びます。

ログイン

<form class="sheet form w-full max-w(380) p-xl">  <header class="flex flex-col items-center gap-xs text-center">    <span class="fg-text-strong">      <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>    </span>    <h1 class="heading heading-lg">Sign in to Atlas</h1>    <p class="m(0) fg-text-muted">Welcome back. Pick up where you left off.</p>  </header>  <div class="flex flex-col gap-xs">    <button type="button" class="btn">      <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="4" cy="3.6667" r="1.6667" /><circle cx="4" cy="12.3333" r="1.6667" /><circle cx="12" cy="3.6667" r="1.6667" /><path d="M4 5.3333L4 10.6667" /><path d="M12 5.3333C12 9.6667 4 7.3333 4 10.6667" />      </svg>Continue with GitHub    </button>    <button type="button" class="btn">      <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="10.6667" cy="5" r="3" /><path d="M8.5467 7.12L2.3333 13.3333" /><path d="M4 11.6667L5.3333 13" /><path d="M6 9.6667L7.3333 11" />      </svg>Continue with a passkey    </button>  </div>  <div class="divider divider-label" role="separator">or</div>  <label class="field">    Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required>  </label>  <div class="field">    <div class="flex items-baseline justify-between gap-sm">      <label for="signin-password">Password</label>      <a class="link link-quiet text-xs fg-text-muted" href="#">Forgot it?</a>    </div>    <input class="input" id="signin-password" type="password" name="password" autocomplete="current-password" required>  </div>  <label class="check">    <input type="checkbox" class="checkbox" name="remember" checked> Keep me signed in on this device  </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>
import ContrastIcon from '@master/icons-react/native/16/soft/contrast'import GitBranchIcon from '@master/icons-react/native/16/soft/git-branch'import KeyIcon from '@master/icons-react/native/16/soft/key'<form className="sheet form w-full max-w(380) p-xl">  <header className="flex flex-col items-center gap-xs text-center">    <span className="fg-text-strong"><ContrastIcon className="icon" /></span>    <h1 className="heading heading-lg">Sign in to Atlas</h1>    <p className="m(0) fg-text-muted">Welcome back. Pick up where you left off.</p>  </header>  <div className="flex flex-col gap-xs">    <button type="button" className="btn">      <GitBranchIcon className="icon" />Continue with GitHub    </button>    <button type="button" className="btn">      <KeyIcon className="icon" />Continue with a passkey    </button>  </div>  <div className="divider divider-label" role="separator">or</div>  <label className="field">    Email<input className="input" type="email" name="email" autoComplete="username" placeholder="you@example.com" required />  </label>  <div className="field">    <div className="flex items-baseline justify-between gap-sm">      <label htmlFor="signin-password">Password</label>      <a className="link link-quiet text-xs fg-text-muted" href="#">Forgot it?</a>    </div>    <input className="input" id="signin-password" type="password" name="password" autoComplete="current-password" required />  </div>  <label className="check">    <input type="checkbox" className="checkbox" name="remember" defaultChecked /> Keep me signed in on this device  </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>
<script>  import ContrastIcon from '@master/icons-svelte/native/16/soft/contrast'  import GitBranchIcon from '@master/icons-svelte/native/16/soft/git-branch'  import KeyIcon from '@master/icons-svelte/native/16/soft/key'</script><form class="sheet form w-full max-w(380) p-xl">  <header class="flex flex-col items-center gap-xs text-center">    <span class="fg-text-strong"><ContrastIcon class="icon" /></span>    <h1 class="heading heading-lg">Sign in to Atlas</h1>    <p class="m(0) fg-text-muted">Welcome back. Pick up where you left off.</p>  </header>  <div class="flex flex-col gap-xs">    <button type="button" class="btn"><GitBranchIcon class="icon" />Continue with GitHub</button>    <button type="button" class="btn"><KeyIcon class="icon" />Continue with a passkey</button>  </div>  <div class="divider divider-label" role="separator">or</div>  <label class="field">    Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required>  </label>  <div class="field">    <div class="flex items-baseline justify-between gap-sm">      <label for="signin-password">Password</label>      <a class="link link-quiet text-xs fg-text-muted" href="#">Forgot it?</a>    </div>    <input class="input" id="signin-password" type="password" name="password" autocomplete="current-password" required>  </div>  <label class="check">    <input type="checkbox" class="checkbox" name="remember" checked> Keep me signed in on this device  </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>
<script setup>import ContrastIcon from '@master/icons-vue/native/16/soft/contrast'import GitBranchIcon from '@master/icons-vue/native/16/soft/git-branch'import KeyIcon from '@master/icons-vue/native/16/soft/key'</script><template>  <form class="sheet form w-full max-w(380) p-xl">    <header class="flex flex-col items-center gap-xs text-center">      <span class="fg-text-strong"><ContrastIcon class="icon" /></span>      <h1 class="heading heading-lg">Sign in to Atlas</h1>      <p class="m(0) fg-text-muted">Welcome back. Pick up where you left off.</p>    </header>    <div class="flex flex-col gap-xs">      <button type="button" class="btn"><GitBranchIcon class="icon" />Continue with GitHub</button>      <button type="button" class="btn"><KeyIcon class="icon" />Continue with a passkey</button>    </div>    <div class="divider divider-label" role="separator">or</div>    <label class="field">      Email<input class="input" type="email" name="email" autocomplete="username" placeholder="you@example.com" required>    </label>    <div class="field">      <div class="flex items-baseline justify-between gap-sm">        <label for="signin-password">Password</label>        <a class="link link-quiet text-xs fg-text-muted" href="#">Forgot it?</a>      </div>      <input class="input" id="signin-password" type="password" name="password" autocomplete="current-password" required>    </div>    <label class="check">      <input type="checkbox" class="checkbox" name="remember" checked> Keep me signed in on this device    </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></template>

ブロックはコピーして使えるマークアップです。文字色と文字サイズはページから引き継ぎます。プレビューでは body に fg-text-body text-sm を設定しています。各ブロックはサイズコンテナーで、広いページでも、サイドバーほどの幅でも、ダイアログ内でも、自身の幅に応じて配置が変わります。カードをページの中央に置くには、中央配置レイアウトを使います。

#構成

  • sheet form w-full max-w(380) p-xl。 スマートフォンではカードが幅いっぱいに広がり、最大幅は 380px です。カード内の要素間隔は form で設定します。
  • すぐに使えるログイン手段を先に。 外部サービスでもパスキーでも、ワンクリックでログインできます。パスワードはフォールバックです。「または」と書いた区切り線で分けます。
  • 「パスワードをお忘れですか?」はラベルの横に。 link-quiet を使い、ラベルと同じ行の終端に控えめな文字色で配置します。これならボタンより目立たず、見つけやすくなります。入力欄はラベルの外にあるため、for でラベルと入力欄を関連付けます。
  • プライマリーボタンは1つ。 最後の操作要素として、入力欄と同じ幅で配置します。
  • もう一方のカードへの案内はボタンの下に。 1行にリンクを1つだけ置きます。

入力欄の autocomplete に username と current-password を指定すると、パスワードマネージャーで自動入力できます。

#アカウント登録

同じカードに入力欄を追加します。姓と名は合わせて1つの回答になる短い入力欄なので、grid grid-cols(2) gap-sm で同じ行に並べます。form-row はフォームの幅が 28rem になってから横並びに切り替わるため、幅が 22rem のこのカードでは横に並びません。パスワードの条件は field-hint に記載し、aria-describedby で入力欄に関連付けて、入力ミスが起きる前に示します。

アカウント登録

<form class="sheet form w-full max-w(420) p-xl">  <header class="flex flex-col gap-xs">    <h1 class="heading heading-lg">Create your account</h1>    <p class="m(0) fg-text-muted">Free for personal projects. No card needed.</p>  </header>  <div class="grid grid-cols(2) gap-sm">    <label class="field">      First name<input class="input" name="given-name" autocomplete="given-name" required>    </label>    <label class="field">      Last name<input class="input" name="family-name" autocomplete="family-name" required>    </label>  </div>  <label class="field">    Work email<input class="input" type="email" name="email" autocomplete="email" placeholder="you@company.com" required>  </label>  <div class="field">    <label for="signup-password">Password</label>    <input class="input" id="signup-password" type="password" name="password" autocomplete="new-password" minlength="12" required aria-describedby="signup-hint">    <span class="field-hint" id="signup-hint">At least 12 characters. A sentence works well.</span>  </div>  <label class="check">    <input type="checkbox" class="checkbox" name="terms" required><span>      I agree to the <a class="link" href="#">terms</a> and the <a class="link" href="#">privacy policy</a>    </span>  </label>  <button class="btn btn-primary">Create account</button>  <p class="m(0) text-center fg-text-muted">    Already have one? <a class="link" href="#">Sign in</a>  </p></form>
<form className="sheet form w-full max-w(420) p-xl">  <header className="flex flex-col gap-xs">    <h1 className="heading heading-lg">Create your account</h1>    <p className="m(0) fg-text-muted">Free for personal projects. No card needed.</p>  </header>  <div className="grid grid-cols(2) gap-sm">    <label className="field">      First name<input className="input" name="given-name" autoComplete="given-name" required />    </label>    <label className="field">      Last name<input className="input" name="family-name" autoComplete="family-name" required />    </label>  </div>  <label className="field">    Work email<input className="input" type="email" name="email" autoComplete="email" placeholder="you@company.com" required />  </label>  <div className="field">    <label htmlFor="signup-password">Password</label>    <input className="input" id="signup-password" type="password" name="password" autoComplete="new-password" minLength={12} required aria-describedby="signup-hint" />    <span className="field-hint" id="signup-hint">      At least 12 characters. A sentence works well.    </span>  </div>  <label className="check">    <input type="checkbox" className="checkbox" name="terms" required /><span>      I agree to the <a className="link" href="#">terms</a> and the <a className="link" href="#">privacy policy</a>    </span>  </label>  <button className="btn btn-primary">Create account</button>  <p className="m(0) text-center fg-text-muted">    Already have one? <a className="link" href="#">Sign in</a>  </p></form>
<form class="sheet form w-full max-w(420) p-xl">  <header class="flex flex-col gap-xs">    <h1 class="heading heading-lg">Create your account</h1>    <p class="m(0) fg-text-muted">Free for personal projects. No card needed.</p>  </header>  <div class="grid grid-cols(2) gap-sm">    <label class="field">      First name<input class="input" name="given-name" autocomplete="given-name" required>    </label>    <label class="field">      Last name<input class="input" name="family-name" autocomplete="family-name" required>    </label>  </div>  <label class="field">    Work email<input class="input" type="email" name="email" autocomplete="email" placeholder="you@company.com" required>  </label>  <div class="field">    <label for="signup-password">Password</label>    <input class="input" id="signup-password" type="password" name="password" autocomplete="new-password" minlength="12" required aria-describedby="signup-hint">    <span class="field-hint" id="signup-hint">At least 12 characters. A sentence works well.</span>  </div>  <label class="check">    <input type="checkbox" class="checkbox" name="terms" required><span>      I agree to the <a class="link" href="#">terms</a> and the <a class="link" href="#">privacy policy</a>    </span>  </label>  <button class="btn btn-primary">Create account</button>  <p class="m(0) text-center fg-text-muted">    Already have one? <a class="link" href="#">Sign in</a>  </p></form>
<template>  <form class="sheet form w-full max-w(420) p-xl">    <header class="flex flex-col gap-xs">      <h1 class="heading heading-lg">Create your account</h1>      <p class="m(0) fg-text-muted">Free for personal projects. No card needed.</p>    </header>    <div class="grid grid-cols(2) gap-sm">      <label class="field">        First name<input class="input" name="given-name" autocomplete="given-name" required>      </label>      <label class="field">        Last name<input class="input" name="family-name" autocomplete="family-name" required>      </label>    </div>    <label class="field">      Work email<input class="input" type="email" name="email" autocomplete="email" placeholder="you@company.com" required>    </label>    <div class="field">      <label for="signup-password">Password</label>      <input class="input" id="signup-password" type="password" name="password" autocomplete="new-password" minlength="12" required aria-describedby="signup-hint">      <span class="field-hint" id="signup-hint">        At least 12 characters. A sentence works well.      </span>    </div>    <label class="check">      <input type="checkbox" class="checkbox" name="terms" required><span>        I agree to the <a class="link" href="#">terms</a> and the <a class="link" href="#">privacy policy</a>      </span>    </label>    <button class="btn btn-primary">Create account</button>    <p class="m(0) text-center fg-text-muted">      Already have one? <a class="link" href="#">Sign in</a>    </p>  </form></template>

最初の画面で必要な情報だけを尋ねます。入力欄が1つ増えるたびに、登録を始めた人の一部が離脱します。

#確認コードの入力

コード送信後にユーザーが行うのは、コードの入力だけです。中央に確認コード入力欄を置き、送信先のアドレスは通常の文字色で表示し、再送操作は控えめに配置します。

確認コードの入力

<form class="sheet form w-full max-w(380) p-xl">  <header class="flex flex-col items-center gap-xs text-center">    <span class="icon-frame" 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">        <rect x="2.5" y="5" width="15" height="10" rx="1.25" /><path d="M3 6.5L9.8918 10.9305A0.2 0.2 0 0 0 10.1082 10.9305L17 6.5" />      </svg>    </span>    <h1 class="heading heading-lg mt-xs">Check your email</h1>    <p class="m(0) fg-text-muted">      We sent a six-digit code to <span class="fg-text-strong">yiching@atlaslabs.dev</span>. It works for ten minutes.    </p>  </header>  <fieldset class="otp mx-auto" aria-label="Verification code">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" autocomplete="one-time-code" aria-label="Digit 1" value="4">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 2" value="2">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 3">    <span class="otp-separator" aria-hidden="true"></span>    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 4">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 5">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 6">  </fieldset>  <button class="btn btn-primary">Verify</button>  <p class="m(0) text-center fg-text-muted">    Nothing arrived? <button type="button" class="link">Send it again</button>  </p></form><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import MailIcon from '@master/icons-react/native/20/soft/mail'export function Example() {  const root = useRef<HTMLFormElement>(null)  useEffect(() => attach(root.current!), [])  return (    <form ref={root} className="sheet form w-full max-w(380) p-xl">      <header className="flex flex-col items-center gap-xs text-center">        <span className="icon-frame" aria-hidden="true"><MailIcon className="icon" /></span>        <h1 className="heading heading-lg mt-xs">Check your email</h1>        <p className="m(0) fg-text-muted">          We sent a six-digit code to <span className="fg-text-strong">yiching@atlaslabs.dev</span>. It works for ten minutes.        </p>      </header>      <fieldset className="otp mx-auto" aria-label="Verification code">        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} autoComplete="one-time-code" aria-label="Digit 1" defaultValue="4" />        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} aria-label="Digit 2" defaultValue="2" />        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} aria-label="Digit 3" />        <span className="otp-separator" aria-hidden="true"></span>        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} aria-label="Digit 4" />        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} aria-label="Digit 5" />        <input className="otp-slot" inputMode="numeric" pattern="[0-9]" maxLength={1} aria-label="Digit 6" />      </fieldset>      <button className="btn btn-primary">Verify</button>      <p className="m(0) text-center fg-text-muted">        Nothing arrived? <button type="button" className="link">Send it again</button>      </p>    </form>  )}
<script>  import { attach } from '@master/ui/behaviors'  import MailIcon from '@master/icons-svelte/native/20/soft/mail'</script><form class="sheet form w-full max-w(380) p-xl" {@attach attach}>  <header class="flex flex-col items-center gap-xs text-center">    <span class="icon-frame" aria-hidden="true"><MailIcon class="icon" /></span>    <h1 class="heading heading-lg mt-xs">Check your email</h1>    <p class="m(0) fg-text-muted">      We sent a six-digit code to <span class="fg-text-strong">yiching@atlaslabs.dev</span>. It works for ten minutes.    </p>  </header>  <fieldset class="otp mx-auto" aria-label="Verification code">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" autocomplete="one-time-code" aria-label="Digit 1" value="4">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 2" value="2">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 3">    <span class="otp-separator" aria-hidden="true"></span>    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 4">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 5">    <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 6">  </fieldset>  <button class="btn btn-primary">Verify</button>  <p class="m(0) text-center fg-text-muted">    Nothing arrived? <button type="button" class="link">Send it again</button>  </p></form>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import MailIcon from '@master/icons-vue/native/20/soft/mail'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <form ref="root" class="sheet form w-full max-w(380) p-xl">    <header class="flex flex-col items-center gap-xs text-center">      <span class="icon-frame" aria-hidden="true"><MailIcon class="icon" /></span>      <h1 class="heading heading-lg mt-xs">Check your email</h1>      <p class="m(0) fg-text-muted">        We sent a six-digit code to <span class="fg-text-strong">yiching@atlaslabs.dev</span>. It works for ten minutes.      </p>    </header>    <fieldset class="otp mx-auto" aria-label="Verification code">      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" autocomplete="one-time-code" aria-label="Digit 1" value="4">      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 2" value="2">      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 3">      <span class="otp-separator" aria-hidden="true"></span>      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 4">      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 5">      <input class="otp-slot" inputmode="numeric" pattern="[0-9]" maxlength="1" aria-label="Digit 6">    </fieldset>    <button class="btn btn-primary">Verify</button>    <p class="m(0) text-center fg-text-muted">      Nothing arrived? <button type="button" class="link">Send it again</button>    </p>  </form></template>

otp のビヘイビアは、次の枠にフォーカスを移し、貼り付けたコードを各枠に振り分けます。このビヘイビアがなくても、各枠に数字を1桁ずつ入力できます。「コードを再送」は、その場で再送を実行する操作なので、<button> をリンクの見た目で表示します。

#アクセシビリティ

  • カードの見出しは、ページの <h1> です。
  • すべての入力欄に、画面に表示されるラベルを付けます。プレースホルダーには入力例を示し、入力欄の名前はラベルで伝えます。
  • エラーは該当する入力欄のそばに表示します。field-error を追加すると、入力値が無効な間に表示されます。詳しくは入力フィールドを参照してください。
  • 入力内容が有効になるまで送信ボタンを無効にする設計は避けます。送信できるようにしておけば、送信時に不足している項目を伝えられます。
  • 長いパスワードを入力する場合は、「パスワードを表示」する操作も検討します。入力グループ内に控えめなボタンを置き、入力欄の type を切り替えます。