反馈
行内提示
文档流中的提示消息,可标注状态。
本页内容
行内提示是页面文档流中的一条消息,内容与所在页面有关。它采用平坦的表面,带有半像素细线轮廓。状态会给表面添一层浅色,并为图标着色。文字保留墨色,含义始终由文字明确传达。
行内提示
<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 上设置 |