網站導覽

v2.1.0
資料顯示

價格

以易於閱讀的價格格式呈現金額。

本頁內容

價格元件以易於閱讀的方式呈現金額。金額用大字顯示,較小的貨幣符號與金額頂端對齊,計價單位則以低調的樣式對齊文字基線。價格元件沒有自己的底色或外框,可放在方案的卡片裡、商品旁或帳單底部。

價格

<div class="tray flex flex-wrap gap(4) max-w(480) mx-auto">  <div class="card card-flat grow(1) basis(200)">    <div class="card-header">      <h3 class="card-title">Starter</h3>      <p class="card-description">For one person and a few projects.</p>    </div>    <p class="price">      <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span>    </p>    <div class="card-footer"><button class="btn" type="button">Choose Starter</button></div>  </div>  <div class="card card-flat grow(1) basis(200)">    <div class="card-header">      <h3 class="card-title">Team</h3>      <p class="card-description">For a team that ships every day.</p>    </div>    <p class="price">      <s class="price-was"><span class="sr-only">Was</span>$39</s><span class="sr-only">now</span><span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span>    </p>    <div class="card-footer">      <button class="btn btn-primary" type="button">Choose Team</button>    </div>  </div></div>
<div className="tray flex flex-wrap gap(4) max-w(480) mx-auto">  <div className="card card-flat grow(1) basis(200)">    <div className="card-header">      <h3 className="card-title">Starter</h3>      <p className="card-description">For one person and a few projects.</p>    </div>    <p className="price">      <span className="price-currency">$</span><span className="price-amount">9</span><span className="price-period">per month</span>    </p>    <div className="card-footer"><button className="btn" type="button">Choose Starter</button></div>  </div>  <div className="card card-flat grow(1) basis(200)">    <div className="card-header">      <h3 className="card-title">Team</h3>      <p className="card-description">For a team that ships every day.</p>    </div>    <p className="price">      <s className="price-was"><span className="sr-only">Was</span>$39</s><span className="sr-only">now</span><span className="price-currency">$</span><span className="price-amount">29</span><span className="price-period">per month</span>    </p>    <div className="card-footer">      <button className="btn btn-primary" type="button">Choose Team</button>    </div>  </div></div>
<div class="tray flex flex-wrap gap(4) max-w(480) mx-auto">  <div class="card card-flat grow(1) basis(200)">    <div class="card-header">      <h3 class="card-title">Starter</h3>      <p class="card-description">For one person and a few projects.</p>    </div>    <p class="price">      <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span>    </p>    <div class="card-footer"><button class="btn" type="button">Choose Starter</button></div>  </div>  <div class="card card-flat grow(1) basis(200)">    <div class="card-header">      <h3 class="card-title">Team</h3>      <p class="card-description">For a team that ships every day.</p>    </div>    <p class="price">      <s class="price-was"><span class="sr-only">Was</span>$39</s><span class="sr-only">now</span><span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span>    </p>    <div class="card-footer">      <button class="btn btn-primary" type="button">Choose Team</button>    </div>  </div></div>
<template>  <div class="tray flex flex-wrap gap(4) max-w(480) mx-auto">    <div class="card card-flat grow(1) basis(200)">      <div class="card-header">        <h3 class="card-title">Starter</h3>        <p class="card-description">For one person and a few projects.</p>      </div>      <p class="price">        <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span>      </p>      <div class="card-footer"><button class="btn" type="button">Choose Starter</button></div>    </div>    <div class="card card-flat grow(1) basis(200)">      <div class="card-header">        <h3 class="card-title">Team</h3>        <p class="card-description">For a team that ships every day.</p>      </div>      <p class="price">        <s class="price-was"><span class="sr-only">Was</span>$39</s><span class="sr-only">now</span><span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span>      </p>      <div class="card-footer">        <button class="btn btn-primary" type="button">Choose Team</button>      </div>    </div>  </div></template>

#組成

  • price-amount 顯示金額,採用等寬數字和緊湊的字距,也可以用「免費」或「客製報價」等文字。
  • price-currency 顯示貨幣符號。字級不到金額數字字級的一半,頂端與金額對齊,讀起來和金額連在一起,又不會搶走焦點。
  • price-period 顯示計價單位,例如每月、每席或每千次請求。它以較小、較淡的文字對齊基線。請用完整文字表示,因為螢幕閱讀器會將「/mo」念成「slash mo」。
  • price-was 顯示已失效的價格。它放在目前金額前方,以較淡的文字和刪除線呈現。請使用 <s> 標記,表明這段文字已不再正確。

請依閱讀順序排列各部分,先放原價,再放貨幣符號、金額和計價單位。若貨幣符號依慣例放在金額後面,請將 price-currency 放在 price-amount 之後。

#尺寸

金額的預設字級為 36px。price-sm 為 24px,適合放在一列或小卡片中。price-lg 為 56px,適合頁面主打的單一價格。各部分都以金額字級為基準,可用 --price-size 將整組價格按比例調整到上述範圍內的任一尺寸。

尺寸

<p class="price price-sm">  <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span></p><p class="price">  <span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span></p><p class="price price-lg">  <span class="price-currency">€</span><span class="price-amount">1,240</span><span class="price-period">per seat</span></p>
<>  <p className="price price-sm">    <span className="price-currency">$</span><span className="price-amount">9</span><span className="price-period">per month</span>  </p>  <p className="price">    <span className="price-currency">$</span><span className="price-amount">29</span><span className="price-period">per month</span>  </p>  <p className="price price-lg">    <span className="price-currency">€</span><span className="price-amount">1,240</span><span className="price-period">per seat</span>  </p></>
<p class="price price-sm">  <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span></p><p class="price">  <span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span></p><p class="price price-lg">  <span class="price-currency">€</span><span class="price-amount">1,240</span><span class="price-period">per seat</span></p>
<template>  <p class="price price-sm">    <span class="price-currency">$</span><span class="price-amount">9</span><span class="price-period">per month</span>  </p>  <p class="price">    <span class="price-currency">$</span><span class="price-amount">29</span><span class="price-period">per month</span>  </p>  <p class="price price-lg">    <span class="price-currency">€</span><span class="price-amount">1,240</span><span class="price-period">per seat</span>  </p></template>

#價格或統計指標

價格讓使用者衡量需要支付的費用。若要呈現附有標籤和變動資訊的數據,例如本月營收,請使用統計指標。若金額只是眾多儲存格中的一格,請在表格中使用 table-numeric。

#無障礙

  • 各部分會依標記中的順序朗讀,例如「美元 29 每月」。請以文字呈現貨幣符號,切勿使用背景圖片。
  • 部分螢幕閱讀器不會唸出價格帶有刪除線。如果區分原價和現價很重要,請加入視覺上隱藏的文字,例如在舊價格前加上「原價」,在目前金額前加上「現價」。
  • 請在卡片上以文字標示推薦方案,避免只靠金額字級來區分。

#類別

類別說明
price價格維持單行,使用 36px 的等寬數字,字距緊密。
price-sm數字大小為 24px,預設為 36px。搭配 price 使用
price-lg數字大小為 56px,適用於頁面唯一主打的價格。預設為 36px。搭配 price 使用
price-amount顯示數字或「免費」之類的文字
price-currency貨幣符號不到數字的一半大,並與數字頂端對齊
price-period以小字和低對比色顯示計價單位,並與價格的基線對齊,例如每月或每個席位。
price-was失效的舊價格以低對比的刪除線文字顯示在目前金額前。

#自訂屬性

屬性預設值說明
--price-size2.25rem數字的大小,其他部件會隨之縮放

#原始碼

@master/ui/components/price.css
/* * Price: what something costs, set the way a price is read. * The amount is large, in tabular figures with a tight fit. The currency mark is small and hangs from the * top of the figures, level with their cap height; the period is small and quiet on their baseline. A price * that no longer holds stands before the amount, struck through, on a <s>. * Everything is sized from the amount, so one size class or one font-size scales the whole price. */@layer components.ui {  .price {    --price-size: 2.25rem;    display: inline-flex;    align-items: baseline;    min-width: 0;    margin: 0;    color: var(--color-text-strong);    font: var(--font-weight-control) var(--price-size)/1 var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    letter-spacing: -.03em;    white-space: nowrap;    &.price-sm {      --price-size: 1.5rem;    }    &.price-lg {      --price-size: 3.5rem;      letter-spacing: -.04em;    }  }  /* The figures. */  .price-amount {    font: inherit;  }  /* The currency mark: under half the size of the figures, its top level with theirs. */  .price-currency {    align-self: flex-start;    margin-block-start: .16em;    margin-inline-end: .14em;    color: var(--color-text-body);    font-size: .46em;    letter-spacing: 0;    line-height: 1;  }  /* Per what: a month, a seat, a thousand requests. */  .price-period {    margin-inline-start: .3em;    color: var(--color-text-muted);    font-weight: 400;    font-size: max(.8125rem, .36em);    letter-spacing: 0;  }  /* The price that no longer holds: quiet, struck, before the one that does. */  .price-was {    margin-inline-end: .5em;    color: var(--color-text-muted);    font-weight: 400;    font-size: .5em;    letter-spacing: -.01em;    text-decoration-line: line-through;    /* The strike grows with the figures it crosses. */    text-decoration-thickness: max(1px, .07em);    text-decoration-color: var(--color-line-mark);  }}