数据展示
价格
按价格的阅读习惯排版,显示商品或服务的费用。
本页内容
价格表示购买商品或服务所需的费用,按阅读习惯排版:金额用大号字,较小的货币符号与金额顶部对齐,计费单位与金额基线对齐,视觉上更弱。价格组件本身不带独立背景。可将它放在套餐的卡片中、商品旁边或发票底部。
价格
<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 将整个价格等比缩放到 24px 和 56px 之间的任意尺寸。
尺寸
<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。
#无障碍
- 各部分按书写顺序朗读,例如“美元、二十九、每月”。货币符号须保留为文本,不能用背景图片呈现。
- 部分屏幕阅读器不会提示价格带有删除线。需要明确区分新旧价格时,可添加视觉上隐藏的文字,例如在旧价前加“原价”,在当前金额前加“现价”。
- 在卡片中用文字明确标出推荐套餐,避免只靠金额字号传达推荐信息。
#类名
| 类名 | 说明 |
|---|---|
price | 价格单行显示,36px 的数字采用等宽数字样式,排列紧凑 |
price-sm | 字号为 24px,默认字号为 36px。与 price 一同使用 |
price-lg | 字号为 56px,用于页面着重展示的唯一一项价格。默认字号为 36px。与 price 一同使用 |
price-amount | 显示金额或“免费”等文字 |
price-currency | 货币符号的字号不到数字的一半,并与数字顶部对齐。 |
price-period | 计价单位,如每月或每席位。使用低调的小字,与价格基线对齐。 |
price-was | 将已失效的价格放在当前金额前,弱化显示并加删除线 |
#自定义属性
| 属性 | 默认值 | 说明 |
|---|---|---|
--price-size | 2.25rem | 数字字号,其他部分随之缩放 |