網站導覽

v2.1.0
應用程式區塊

選擇卡片

以包住原生輸入元件的卡片,選擇方案、人員和付款方式。

選擇卡片用於需要一句話說明才能做出的決定:選哪個方案、由誰審查、如何付款。每個選項都是一個選項元件,也就是包住原生單選按鈕或核取方塊的 <label>,因此整張卡片都是點按目標,輸入元件則負責狀態、鍵盤操作和表單值。不需要任何腳本。

方案

<section class="sheet container-inline p-lg" aria-labelledby="cc-plan-title">  <form class="flex flex-col gap-md">    <fieldset class="fieldset gap-sm">      <legend class="fieldset-legend heading heading-sm" id="cc-plan-title">        Choose a plan for Atlas Labs      </legend>      <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 12rem">        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="hobby">          <span class="choice-body">            <span class="choice-title">Hobby</span>            <span class="price price-sm">              <span class="price-currency">$</span><span class="price-amount">0</span><span class="price-period">per month</span>            </span>            <span class="choice-description">One project, previews for every branch.</span>          </span>        </label>        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="pro" checked>          <span class="choice-body">            <span class="choice-title">Pro</span>            <span class="price price-sm">              <span class="price-currency">$</span><span class="price-amount">20</span><span class="price-period">per seat a month</span>            </span>            <span class="choice-description">              Unlimited projects, fourteen regions and 400 build minutes a seat.            </span>          </span>          <span class="choice-end"><span class="badge badge-sm">Current</span></span>        </label>        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="enterprise">          <span class="choice-body">            <span class="choice-title">Enterprise</span>            <span class="price price-sm"><span class="price-amount">Custom</span></span>            <span class="choice-description">              From 5 seats, single sign-on, an audit log and a 99.99% uptime agreement.            </span>          </span>        </label>      </div>    </fieldset>    <div class="flex flex-wrap items-center justify-between gap-sm">      <p class="m(0) fg-text-muted">Pro, 5 seats: $100 a month, billed on the 1st.</p>      <button class="btn btn-primary btn-sm">Keep Pro</button>    </div>  </form></section>
<section className="sheet container-inline p-lg" aria-labelledby="cc-plan-title">  <form className="flex flex-col gap-md">    <fieldset className="fieldset gap-sm">      <legend className="fieldset-legend heading heading-sm" id="cc-plan-title">        Choose a plan for Atlas Labs      </legend>      <div className="auto-grid auto-grid-fit gap-sm" style={{ '--auto-grid-min': '12rem' } as React.CSSProperties}>        <label className="choice">          <input type="radio" className="radio" name="cc-plan" value="hobby" />          <span className="choice-body">            <span className="choice-title">Hobby</span>            <span className="price price-sm">              <span className="price-currency">$</span><span className="price-amount">0</span><span className="price-period">per month</span>            </span>            <span className="choice-description">One project, previews for every branch.</span>          </span>        </label>        <label className="choice">          <input type="radio" className="radio" name="cc-plan" value="pro" defaultChecked />          <span className="choice-body">            <span className="choice-title">Pro</span>            <span className="price price-sm">              <span className="price-currency">$</span><span className="price-amount">20</span><span className="price-period">per seat a month</span>            </span>            <span className="choice-description">              Unlimited projects, fourteen regions and 400 build minutes a seat.            </span>          </span>          <span className="choice-end"><span className="badge badge-sm">Current</span></span>        </label>        <label className="choice">          <input type="radio" className="radio" name="cc-plan" value="enterprise" />          <span className="choice-body">            <span className="choice-title">Enterprise</span>            <span className="price price-sm"><span className="price-amount">Custom</span></span>            <span className="choice-description">              From 5 seats, single sign-on, an audit log and a 99.99% uptime agreement.            </span>          </span>        </label>      </div>    </fieldset>    <div className="flex flex-wrap items-center justify-between gap-sm">      <p className="m(0) fg-text-muted">Pro, 5 seats: $100 a month, billed on the 1st.</p>      <button className="btn btn-primary btn-sm">Keep Pro</button>    </div>  </form></section>
<section class="sheet container-inline p-lg" aria-labelledby="cc-plan-title">  <form class="flex flex-col gap-md">    <fieldset class="fieldset gap-sm">      <legend class="fieldset-legend heading heading-sm" id="cc-plan-title">        Choose a plan for Atlas Labs      </legend>      <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 12rem">        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="hobby">          <span class="choice-body">            <span class="choice-title">Hobby</span>            <span class="price price-sm">              <span class="price-currency">$</span><span class="price-amount">0</span><span class="price-period">per month</span>            </span>            <span class="choice-description">One project, previews for every branch.</span>          </span>        </label>        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="pro" checked>          <span class="choice-body">            <span class="choice-title">Pro</span>            <span class="price price-sm">              <span class="price-currency">$</span><span class="price-amount">20</span><span class="price-period">per seat a month</span>            </span>            <span class="choice-description">              Unlimited projects, fourteen regions and 400 build minutes a seat.            </span>          </span>          <span class="choice-end"><span class="badge badge-sm">Current</span></span>        </label>        <label class="choice">          <input type="radio" class="radio" name="cc-plan" value="enterprise">          <span class="choice-body">            <span class="choice-title">Enterprise</span>            <span class="price price-sm"><span class="price-amount">Custom</span></span>            <span class="choice-description">              From 5 seats, single sign-on, an audit log and a 99.99% uptime agreement.            </span>          </span>        </label>      </div>    </fieldset>    <div class="flex flex-wrap items-center justify-between gap-sm">      <p class="m(0) fg-text-muted">Pro, 5 seats: $100 a month, billed on the 1st.</p>      <button class="btn btn-primary btn-sm">Keep Pro</button>    </div>  </form></section>
<template>  <section class="sheet container-inline p-lg" aria-labelledby="cc-plan-title">    <form class="flex flex-col gap-md">      <fieldset class="fieldset gap-sm">        <legend class="fieldset-legend heading heading-sm" id="cc-plan-title">          Choose a plan for Atlas Labs        </legend>        <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 12rem">          <label class="choice">            <input type="radio" class="radio" name="cc-plan" value="hobby">            <span class="choice-body">              <span class="choice-title">Hobby</span>              <span class="price price-sm">                <span class="price-currency">$</span><span class="price-amount">0</span><span class="price-period">per month</span>              </span>              <span class="choice-description">One project, previews for every branch.</span>            </span>          </label>          <label class="choice">            <input type="radio" class="radio" name="cc-plan" value="pro" checked>            <span class="choice-body">              <span class="choice-title">Pro</span>              <span class="price price-sm">                <span class="price-currency">$</span><span class="price-amount">20</span><span class="price-period">per seat a month</span>              </span>              <span class="choice-description">                Unlimited projects, fourteen regions and 400 build minutes a seat.              </span>            </span>            <span class="choice-end"><span class="badge badge-sm">Current</span></span>          </label>          <label class="choice">            <input type="radio" class="radio" name="cc-plan" value="enterprise">            <span class="choice-body">              <span class="choice-title">Enterprise</span>              <span class="price price-sm"><span class="price-amount">Custom</span></span>              <span class="choice-description">                From 5 seats, single sign-on, an audit log and a 99.99% uptime agreement.              </span>            </span>          </label>        </div>      </fieldset>      <div class="flex flex-wrap items-center justify-between gap-sm">        <p class="m(0) fg-text-muted">Pro, 5 seats: $100 a month, billed on the 1st.</p>        <button class="btn btn-primary btn-sm">Keep Pro</button>      </div>    </form>  </section></template>

區塊提供可直接複製的標記,沿用頁面的文字顏色和字級。預覽在 body 上設定 fg-text-body text-sm。每個區塊都是尺寸容器,無論放在寬大的頁面、側邊欄大小的空間,還是對話框裡,都會依自身寬度重新排列。

#組成

  • 一個帶有 <legend> 的 <fieldset>。 legend 是問題,並為這組單選按鈕命名,因此每個選項都會被當成對這個問題的回答來朗讀。它以 heading heading-sm 套用標題的字體樣式。
  • 每個選項都是一個選項元件。 單選按鈕位於開頭;被選取的卡片會浮起,外框會加深,讀者不需辨識色相就能看出,單選按鈕本身的標記也表達同樣的狀態。
  • 由文字承載決定所需的資訊。 標題、有價格時的價格,以及一句說明該選項提供什麼的句子。目前適用的項目(目前的方案或預設的付款方式)會在第一行末端以中性的徽章標示。
  • 卡片依區塊的寬度重新排列。 搭配 --auto-grid-min 的 auto-grid auto-grid-fit,在寬敞的空間中讓方案並排並平分整列,在狹窄的空間中則上下排列;不需要撰寫任何斷點。
  • 摘要與選擇一致。 操作按鈕前的那一行會說明所選選項依目前席位數計算的費用,操作按鈕也會寫出所選的選項。

#人員

可以選擇多個項目時使用核取方塊,例如由誰審查、通知誰。每張卡片包含該成員的頭像、姓名和角色。卡片下方的一行文字說明已選取幾人以及其意義,並用來描述這個 fieldset。

人員

<section class="sheet container-inline p-lg" aria-labelledby="cc-people-title">  <fieldset class="fieldset gap-sm" aria-describedby="cc-people-count">    <legend class="fieldset-legend heading heading-sm" id="cc-people-title">      Who reviews deployments to production?    </legend>    <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 16rem">      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="yiching@atlaslabs.dev" checked>        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/yiching-lin.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Yi-ching Lin</span>          <span class="choice-description">Owner</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="misaki@atlaslabs.dev" checked>        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Misaki Sato</span>          <span class="choice-description">Admin</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="jihoon@atlaslabs.dev">        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/jihoon-park.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Ji-hoon Park</span>          <span class="choice-description">Member</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="kenta@atlaslabs.dev">        <span class="avatar avatar-sm" aria-hidden="true">KN</span>        <span class="choice-body">          <span class="choice-title">Kenta Nakamura</span>          <span class="choice-description">Member</span>        </span>      </label>    </div>    <p class="m(0) fg-text-muted" id="cc-people-count">      2 of 4 people review. One approval is enough to deploy.    </p>  </fieldset></section>
<section className="sheet container-inline p-lg" aria-labelledby="cc-people-title">  <fieldset className="fieldset gap-sm" aria-describedby="cc-people-count">    <legend className="fieldset-legend heading heading-sm" id="cc-people-title">      Who reviews deployments to production?    </legend>    <div className="auto-grid auto-grid-fit gap-sm" style={{ '--auto-grid-min': '16rem' } as React.CSSProperties}>      <label className="choice items-center">        <input type="checkbox" className="checkbox" name="cc-reviewers" value="yiching@atlaslabs.dev" defaultChecked />        <span className="avatar avatar-sm">          <img className="avatar-image" src="/demo/people/yiching-lin.webp" alt="" width="256" height="256" />        </span>        <span className="choice-body">          <span className="choice-title">Yi-ching Lin</span>          <span className="choice-description">Owner</span>        </span>      </label>      <label className="choice items-center">        <input type="checkbox" className="checkbox" name="cc-reviewers" value="misaki@atlaslabs.dev" defaultChecked />        <span className="avatar avatar-sm">          <img className="avatar-image" src="/demo/people/misaki-sato.webp" alt="" width="256" height="256" />        </span>        <span className="choice-body">          <span className="choice-title">Misaki Sato</span>          <span className="choice-description">Admin</span>        </span>      </label>      <label className="choice items-center">        <input type="checkbox" className="checkbox" name="cc-reviewers" value="jihoon@atlaslabs.dev" />        <span className="avatar avatar-sm">          <img className="avatar-image" src="/demo/people/jihoon-park.webp" alt="" width="256" height="256" />        </span>        <span className="choice-body">          <span className="choice-title">Ji-hoon Park</span>          <span className="choice-description">Member</span>        </span>      </label>      <label className="choice items-center">        <input type="checkbox" className="checkbox" name="cc-reviewers" value="kenta@atlaslabs.dev" />        <span className="avatar avatar-sm" aria-hidden="true">KN</span>        <span className="choice-body">          <span className="choice-title">Kenta Nakamura</span>          <span className="choice-description">Member</span>        </span>      </label>    </div>    <p className="m(0) fg-text-muted" id="cc-people-count">      2 of 4 people review. One approval is enough to deploy.    </p>  </fieldset></section>
<section class="sheet container-inline p-lg" aria-labelledby="cc-people-title">  <fieldset class="fieldset gap-sm" aria-describedby="cc-people-count">    <legend class="fieldset-legend heading heading-sm" id="cc-people-title">      Who reviews deployments to production?    </legend>    <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 16rem">      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="yiching@atlaslabs.dev" checked>        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/yiching-lin.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Yi-ching Lin</span>          <span class="choice-description">Owner</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="misaki@atlaslabs.dev" checked>        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Misaki Sato</span>          <span class="choice-description">Admin</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="jihoon@atlaslabs.dev">        <span class="avatar avatar-sm">          <img class="avatar-image" src="/demo/people/jihoon-park.webp" alt width="256" height="256">        </span>        <span class="choice-body">          <span class="choice-title">Ji-hoon Park</span>          <span class="choice-description">Member</span>        </span>      </label>      <label class="choice items-center">        <input type="checkbox" class="checkbox" name="cc-reviewers" value="kenta@atlaslabs.dev">        <span class="avatar avatar-sm" aria-hidden="true">KN</span>        <span class="choice-body">          <span class="choice-title">Kenta Nakamura</span>          <span class="choice-description">Member</span>        </span>      </label>    </div>    <p class="m(0) fg-text-muted" id="cc-people-count">      2 of 4 people review. One approval is enough to deploy.    </p>  </fieldset></section>
<template>  <section class="sheet container-inline p-lg" aria-labelledby="cc-people-title">    <fieldset class="fieldset gap-sm" aria-describedby="cc-people-count">      <legend class="fieldset-legend heading heading-sm" id="cc-people-title">        Who reviews deployments to production?      </legend>      <div class="auto-grid auto-grid-fit gap-sm" style="--auto-grid-min: 16rem">        <label class="choice items-center">          <input type="checkbox" class="checkbox" name="cc-reviewers" value="yiching@atlaslabs.dev" checked>          <span class="avatar avatar-sm">            <img class="avatar-image" src="/demo/people/yiching-lin.webp" alt width="256" height="256">          </span>          <span class="choice-body">            <span class="choice-title">Yi-ching Lin</span>            <span class="choice-description">Owner</span>          </span>        </label>        <label class="choice items-center">          <input type="checkbox" class="checkbox" name="cc-reviewers" value="misaki@atlaslabs.dev" checked>          <span class="avatar avatar-sm">            <img class="avatar-image" src="/demo/people/misaki-sato.webp" alt width="256" height="256">          </span>          <span class="choice-body">            <span class="choice-title">Misaki Sato</span>            <span class="choice-description">Admin</span>          </span>        </label>        <label class="choice items-center">          <input type="checkbox" class="checkbox" name="cc-reviewers" value="jihoon@atlaslabs.dev">          <span class="avatar avatar-sm">            <img class="avatar-image" src="/demo/people/jihoon-park.webp" alt width="256" height="256">          </span>          <span class="choice-body">            <span class="choice-title">Ji-hoon Park</span>            <span class="choice-description">Member</span>          </span>        </label>        <label class="choice items-center">          <input type="checkbox" class="checkbox" name="cc-reviewers" value="kenta@atlaslabs.dev">          <span class="avatar avatar-sm" aria-hidden="true">KN</span>          <span class="choice-body">            <span class="choice-title">Kenta Nakamura</span>            <span class="choice-description">Member</span>          </span>        </label>      </div>      <p class="m(0) fg-text-muted" id="cc-people-count">        2 of 4 people review. One approval is enough to deploy.      </p>    </fieldset>  </section></template>

#付款方式

一次選擇一種已儲存的付款方式。付款方式以讀者認得的資訊命名,也就是品牌和末四碼,並加上區分它們的資訊:到期時間、處理所需時間、剩餘的額度。圖示框中的圖示只是裝飾,由標題說明它是什麼。

付款方式

<section class="sheet container-inline p-lg" aria-labelledby="cc-method-title">  <form class="flex flex-col gap-md">    <fieldset class="fieldset gap-sm">      <legend class="fieldset-legend heading heading-sm" id="cc-method-title">        Pay the invoice of November with      </legend>      <div class="flex flex-col gap-xs">        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="visa-ending-in-4821" checked>          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <rect x="1.6667" y="3.3333" width="12.6667" height="9.3333" rx="1" /><path d="M1.6667 6.6667L14.3333 6.6667" /><path d="M4 10L6.6667 10" />            </svg>          </span>          <span class="choice-body">            <span class="choice-title">Visa ending in 4821</span>            <span class="choice-description">Expires 08/2028</span>          </span>          <span class="choice-end"><span class="badge badge-sm">Default</span></span>        </label>        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="bank-account-ending-in-7310">          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <path d="M2.6747 4.9585L7.9029 2.054A0.2 0.2 0 0 1 8.0971 2.054L13.3253 4.9585A0.2 0.2 0 0 1 13.2282 5.3333L2.7718 5.3333A0.2 0.2 0 0 1 2.6747 4.9585Z" /><path d="M4 7.3333L4 11.6667" /><path d="M8 7.3333L8 11.6667" /><path d="M12 7.3333L12 11.6667" /><path d="M2 14L14 14" />            </svg>          </span>          <span class="choice-body">            <span class="choice-title">Bank account ending in 7310</span>            <span class="choice-description">Direct debit, 3 days to settle</span>          </span>        </label>        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="atlas-credit">          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">              <rect x="2" y="5.3333" width="12" height="2.6667" rx="0.8" /><path d="M3.3333 8L3.3333 13A1 1 0 0 0 4.3333 14L11.6667 14A1 1 0 0 0 12.6667 13L12.6667 8" /><path d="M8 5.3333L8 14" /><path d="M8 5.3333C5.3333 5.3333 3.6667 4.6667 3.6667 3C3.6667 0.6667 7.3333 1.6667 8 5.3333C8.6667 1.6667 12.3333 0.6667 12.3333 3C12.3333 4.6667 10.6667 5.3333 8 5.3333" />            </svg>          </span>          <span class="choice-body">            <span class="choice-title">Atlas credit</span>            <span class="choice-description">$120.00 left, until 31 March</span>          </span>        </label>      </div>    </fieldset>    <div class="flex flex-wrap items-center justify-between gap-sm">      <a class="btn btn-quiet btn-sm" href="#cc-method-title">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M3 8L13 8" /><path d="M8 3L8 13" />        </svg>Add a payment method      </a>      <button class="btn btn-primary btn-sm">Pay $100.00</button>    </div>  </form></section>
import CreditCardIcon from '@master/icons-react/native/16/soft/credit-card'import LandmarkIcon from '@master/icons-react/native/16/soft/landmark'import GiftIcon from '@master/icons-react/native/16/soft/gift'import PlusIcon from '@master/icons-react/native/16/soft/plus'<section className="sheet container-inline p-lg" aria-labelledby="cc-method-title">  <form className="flex flex-col gap-md">    <fieldset className="fieldset gap-sm">      <legend className="fieldset-legend heading heading-sm" id="cc-method-title">        Pay the invoice of November with      </legend>      <div className="flex flex-col gap-xs">        <label className="choice items-center">          <input type="radio" className="radio" name="cc-method" value="visa-ending-in-4821" defaultChecked />          <span className="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <CreditCardIcon className="icon" />          </span>          <span className="choice-body">            <span className="choice-title">Visa ending in 4821</span>            <span className="choice-description">Expires 08/2028</span>          </span>          <span className="choice-end"><span className="badge badge-sm">Default</span></span>        </label>        <label className="choice items-center">          <input type="radio" className="radio" name="cc-method" value="bank-account-ending-in-7310" />          <span className="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <LandmarkIcon className="icon" />          </span>          <span className="choice-body">            <span className="choice-title">Bank account ending in 7310</span>            <span className="choice-description">Direct debit, 3 days to settle</span>          </span>        </label>        <label className="choice items-center">          <input type="radio" className="radio" name="cc-method" value="atlas-credit" />          <span className="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <GiftIcon className="icon" />          </span>          <span className="choice-body">            <span className="choice-title">Atlas credit</span>            <span className="choice-description">$120.00 left, until 31 March</span>          </span>        </label>      </div>    </fieldset>    <div className="flex flex-wrap items-center justify-between gap-sm">      <a className="btn btn-quiet btn-sm" href="#cc-method-title">        <PlusIcon className="icon" />Add a payment method      </a>      <button className="btn btn-primary btn-sm">Pay $100.00</button>    </div>  </form></section>
<script>  import CreditCardIcon from '@master/icons-svelte/native/16/soft/credit-card'  import LandmarkIcon from '@master/icons-svelte/native/16/soft/landmark'  import GiftIcon from '@master/icons-svelte/native/16/soft/gift'  import PlusIcon from '@master/icons-svelte/native/16/soft/plus'</script><section class="sheet container-inline p-lg" aria-labelledby="cc-method-title">  <form class="flex flex-col gap-md">    <fieldset class="fieldset gap-sm">      <legend class="fieldset-legend heading heading-sm" id="cc-method-title">        Pay the invoice of November with      </legend>      <div class="flex flex-col gap-xs">        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="visa-ending-in-4821" checked>          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <CreditCardIcon class="icon" />          </span>          <span class="choice-body">            <span class="choice-title">Visa ending in 4821</span>            <span class="choice-description">Expires 08/2028</span>          </span>          <span class="choice-end"><span class="badge badge-sm">Default</span></span>        </label>        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="bank-account-ending-in-7310">          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <LandmarkIcon class="icon" />          </span>          <span class="choice-body">            <span class="choice-title">Bank account ending in 7310</span>            <span class="choice-description">Direct debit, 3 days to settle</span>          </span>        </label>        <label class="choice items-center">          <input type="radio" class="radio" name="cc-method" value="atlas-credit">          <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">            <GiftIcon class="icon" />          </span>          <span class="choice-body">            <span class="choice-title">Atlas credit</span>            <span class="choice-description">$120.00 left, until 31 March</span>          </span>        </label>      </div>    </fieldset>    <div class="flex flex-wrap items-center justify-between gap-sm">      <a class="btn btn-quiet btn-sm" href="#cc-method-title">        <PlusIcon class="icon" />Add a payment method      </a>      <button class="btn btn-primary btn-sm">Pay $100.00</button>    </div>  </form></section>
<script setup>import CreditCardIcon from '@master/icons-vue/native/16/soft/credit-card'import LandmarkIcon from '@master/icons-vue/native/16/soft/landmark'import GiftIcon from '@master/icons-vue/native/16/soft/gift'import PlusIcon from '@master/icons-vue/native/16/soft/plus'</script><template>  <section class="sheet container-inline p-lg" aria-labelledby="cc-method-title">    <form class="flex flex-col gap-md">      <fieldset class="fieldset gap-sm">        <legend class="fieldset-legend heading heading-sm" id="cc-method-title">          Pay the invoice of November with        </legend>        <div class="flex flex-col gap-xs">          <label class="choice items-center">            <input type="radio" class="radio" name="cc-method" value="visa-ending-in-4821" checked>            <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">              <CreditCardIcon class="icon" />            </span>            <span class="choice-body">              <span class="choice-title">Visa ending in 4821</span>              <span class="choice-description">Expires 08/2028</span>            </span>            <span class="choice-end"><span class="badge badge-sm">Default</span></span>          </label>          <label class="choice items-center">            <input type="radio" class="radio" name="cc-method" value="bank-account-ending-in-7310">            <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">              <LandmarkIcon class="icon" />            </span>            <span class="choice-body">              <span class="choice-title">Bank account ending in 7310</span>              <span class="choice-description">Direct debit, 3 days to settle</span>            </span>          </label>          <label class="choice items-center">            <input type="radio" class="radio" name="cc-method" value="atlas-credit">            <span class="icon-frame icon-frame-xs icon-frame-raised" aria-hidden="true">              <GiftIcon class="icon" />            </span>            <span class="choice-body">              <span class="choice-title">Atlas credit</span>              <span class="choice-description">$120.00 left, until 31 March</span>            </span>          </label>        </div>      </fieldset>      <div class="flex flex-wrap items-center justify-between gap-sm">        <a class="btn btn-quiet btn-sm" href="#cc-method-title">          <PlusIcon class="icon" />Add a payment method        </a>        <button class="btn btn-primary btn-sm">Pay $100.00</button>      </div>    </form>  </section></template>

這個區塊只在已儲存的付款方式之間選擇,從不要求輸入卡號:新增付款方式應使用付款服務供應商自己的表單或頁面,由供應商處理卡號,應用程式不會接觸卡號。

#無障礙

  • 每個區塊都是一個以其 legend 的 id 命名的 <section>,legend 也為 fieldset 命名,讓其中每個選項都有群組脈絡。
  • 每張卡片內的輸入元件都是真正的單選按鈕或核取方塊:方向鍵可在同一組單選按鈕中移動,空白鍵可切換核取方塊,表單則會提交其值。
  • 整張卡片都是點按目標,在觸控螢幕上至少高 44px;焦點外框繪製在卡片周圍,而不是小小的輸入元件上。
  • 選取狀態由輸入元件本身的標記和卡片加深的外框表達,從不只靠色彩。徽章以文字寫出「目前」和「預設」。
  • 姓名旁的頭像只是裝飾:其 alt 留空,姓名縮寫則加上 aria-hidden。