回饋
提示訊息
隨頁面內容排列的訊息,可選擇加上狀態。
本頁內容
提示訊息隨頁面內容排列,說明與所在頁面有關的事。提示訊息採平面樣式,外框為半像素。設定狀態後,背景會帶有淡淡的狀態色,圖示也會套用狀態色。文字沿用原本的高對比色,並明確說明狀態,讓讀者無須靠顏色理解。
提示訊息
<div class="alert" role="status"> <svg class="icon alert-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" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" /><path d="M8 8L8 11" /> </svg> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button></div>import InfoCircleIcon from '@master/icons-react/native/16/soft/info-circle'<div className="alert" role="status"> <InfoCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">A new version is available</p> <p className="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" className="btn btn-sm">Reload</button></div><script> import InfoCircleIcon from '@master/icons-svelte/native/16/soft/info-circle'</script><div class="alert" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button></div><script setup>import InfoCircleIcon from '@master/icons-vue/native/16/soft/info-circle'</script><template> <div class="alert" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">A new version is available</p> <p class="alert-description">Reload to use the latest build of the dashboard.</p> </div> <button type="button" class="btn btn-sm">Reload</button> </div></template>#狀態
依讀者需要採取的行動選擇狀態,並在文字中說清楚。
alert-info補充背景資訊,目前無須採取行動。alert-success確認剛完成的事項。alert-warning提醒讀者在問題發生前留意。alert-danger回報失敗或無法執行的操作。
狀態
<div class="alert alert-info" role="status"> <svg class="icon alert-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" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" /><path d="M8 8L8 11" /> </svg> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div></div><div class="alert alert-success" role="status"> <svg class="icon alert-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="M5 8L7.1041 9.8703A0.2 0.2 0 0 0 7.3832 9.8573L10.75 6.25" /> </svg> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div></div><div class="alert alert-warning" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" /><path d="M8 6.5L8 9" /><circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" /> </svg> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button></div><div class="alert alert-danger" role="alert"> <svg class="icon alert-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" transform="rotate(180 8 8)" /><circle cx="8" cy="5" r="0.5" fill="currentColor" stroke="none" transform="rotate(180 8 8)" /><path d="M8 8L8 11" transform="rotate(180 8 8)" /> </svg> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div></div>import InfoCircleIcon from '@master/icons-react/native/16/soft/info-circle'import CheckCircleIcon from '@master/icons-react/native/16/soft/check-circle'import AlertTriangleIcon from '@master/icons-react/native/16/soft/alert-triangle'import AlertCircleIcon from '@master/icons-react/native/16/soft/alert-circle'<> <div className="alert alert-info" role="status"> <InfoCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div> </div> <div className="alert alert-success" role="status"> <CheckCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-description">Your domain is verified and serving traffic.</p> </div> </div> <div className="alert alert-warning" role="status"> <AlertTriangleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">Your card expires this month</p> <p className="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" className="btn btn-sm">Update</button> </div> <div className="alert alert-danger" role="alert"> <AlertCircleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">The build failed</p> <p className="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div> </div></><script> import InfoCircleIcon from '@master/icons-svelte/native/16/soft/info-circle' import CheckCircleIcon from '@master/icons-svelte/native/16/soft/check-circle' import AlertTriangleIcon from '@master/icons-svelte/native/16/soft/alert-triangle' import AlertCircleIcon from '@master/icons-svelte/native/16/soft/alert-circle'</script><div class="alert alert-info" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div></div><div class="alert alert-success" role="status"> <CheckCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div></div><div class="alert alert-warning" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button></div><div class="alert alert-danger" role="alert"> <AlertCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div></div><script setup>import InfoCircleIcon from '@master/icons-vue/native/16/soft/info-circle'import CheckCircleIcon from '@master/icons-vue/native/16/soft/check-circle'import AlertTriangleIcon from '@master/icons-vue/native/16/soft/alert-triangle'import AlertCircleIcon from '@master/icons-vue/native/16/soft/alert-circle'</script><template> <div class="alert alert-info" role="status"> <InfoCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Scheduled maintenance on Sunday from 02:00 to 03:00 UTC.</p> </div> </div> <div class="alert alert-success" role="status"> <CheckCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-description">Your domain is verified and serving traffic.</p> </div> </div> <div class="alert alert-warning" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Your card expires this month</p> <p class="alert-description">Update the payment method to keep deployments running.</p> </div> <button type="button" class="btn btn-sm">Update</button> </div> <div class="alert alert-danger" role="alert"> <AlertCircleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">The build failed</p> <p class="alert-description"> The install step exited with code 1. Read the logs for the missing dependency. </p> </div> </div></template>#版面配置
提示訊息使用 --alert-radius,預設為 var(--radius-control-lg)。如果直接放在托盤內,請在提示訊息上將這個屬性設為 var(--radius-surface),使圓角與托盤的圓角和內距相配。
在圖示上加上 icon alert-icon。無論後面有幾行文字,圖示都會對齊第一行的中央。alert-body 會占用剩餘寬度。放在內文之後的按鈕或連結會排在列尾,提示訊息較窄時則換到文字下方。
放在窄欄中
<div class="alert alert-warning max-w(280) mx-auto" role="status"> <svg class="icon alert-icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"> <path d="M8.8742 3.8235L13.4246 12.0144A1 1 0 0 1 12.5505 13.5L3.4495 13.5A1 1 0 0 1 2.5754 12.0144L7.1258 3.8235A1 1 0 0 1 8.8742 3.8235Z" /><path d="M8 6.5L8 9" /><circle cx="8" cy="11.5" r="0.5" fill="currentColor" stroke="none" /> </svg> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button></div>import AlertTriangleIcon from '@master/icons-react/native/16/soft/alert-triangle'<div className="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon className="icon alert-icon" /> <div className="alert-body"> <p className="alert-title">Usage is at 90%</p> <p className="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" className="btn btn-sm">Upgrade</button></div><script> import AlertTriangleIcon from '@master/icons-svelte/native/16/soft/alert-triangle'</script><div class="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button></div><script setup>import AlertTriangleIcon from '@master/icons-vue/native/16/soft/alert-triangle'</script><template> <div class="alert alert-warning max-w(280) mx-auto" role="status"> <AlertTriangleIcon class="icon alert-icon" /> <div class="alert-body"> <p class="alert-title">Usage is at 90%</p> <p class="alert-description">Requests are limited when the plan runs out.</p> </div> <button type="button" class="btn btn-sm">Upgrade</button> </div></template>#無障礙
- 在頁面載入後才出現的提示訊息需要即時區域。
role="status"會等到目前的朗讀暫停再播報,role="alert"則會打斷朗讀。只在失敗且需要立即處理時使用role="alert"。 - 一開始就隨頁面呈現的提示訊息無須設定角色。
- 將圖示標記為
aria-hidden="true",由文字傳達完整訊息。
#類別
| 類別 | 說明 |
|---|---|
alert | 中性訊息採用平面樣式,外框寬半個像素。內文後的按鈕或連結位於列尾,警示寬度不足時會換到內文下方。 |
alert-info | 用於暫時不影響操作的補充資訊,以資訊色顯示淡色底和圖示搭配 alert 使用 |
alert-success | 剛完成的操作以淡底色和圖示呈現,兩者皆採用成功狀態的色調搭配 alert 使用 |
alert-warning | 提醒使用者留意潛在問題,背景和圖示都採用警告色,背景色較淡。搭配 alert 使用 |
alert-danger | 表示失敗或操作受阻,背景和圖示都採用危險色,背景色較淡。搭配 alert 使用 |
alert-icon | 在圖示上搭配 icon 使用,讓圖示垂直對齊第一行文字的中央,後續換行不影響對齊 |
alert-body | 容納文字並占滿剩餘寬度 |
alert-title | 以簡短醒目的文字呈現訊息重點。 |
alert-description | 標題下方的一句話。警示沒有標題時,這句話就是完整訊息 |
#自訂屬性
| 屬性 | 預設值 | 說明 |
|---|---|---|
--alert-radius | var(--radius-control-lg) | 套用圓角縮放前的圓弧半徑。警示直接置於托盤內時,使用 var(--radius-surface)。設定於 alert |