警报对话框
模式对话框,用重要内容打断用户并期望得到响应。
用途
Include CSS
导入 Tailwind 和一个完整的 A3S UI 样式包。
或者仅导入基本 CSS、诊断对话框组件 CSS 和一个样式包。
警报对话框使用对话框组件CSS。
使用CDN或批量程序导入?请参见安装页。
Add your alert dialog HTML
Alert Dialog uses a native <dialog class="alert-dialog"> element. Omit the close button and backdrop-click handler when the user must choose an explicit action.
HTML 结构
<button type="button" onclick="dialog.showModal()">Optional- Trigger button. A3S UI uses the native
HTMLDialogElement.showModal()method. <dialog class="alert-dialog" id="{ DIALOG_ID }">Native modal dialog. Add
aria-labelledbyandaria-describedbywhen title and description are present. Usedata-size="sm"for the compact upstream size.<div>Dialog content surface.
<header>Alert dialog header.
<figure>Optional- Media area for an icon or image.
<h2 id="{ TITLE_ID }">- Alert dialog title. Reference it from
aria-labelledby. <p id="{ DESCRIPTION_ID }">Optional- Alert dialog description. Reference it from
aria-describedby.
<footer>- Action area. Include a cancel action and the primary action.
示例
基本
带有标题、描述以及取消和继续按钮的基本警报对话框。
媒体
Use a <figure> in the header to add a media element such as an icon or image to the alert dialog.
破坏性
当警报对话框确认破坏性操作时,使用破坏性操作按钮。
小
使用 data-size="sm" 实现紧凑的警报对话框。小尺寸使媒体、标题和描述堆叠在一起,并将操作按钮集中在两列页脚中。
RTL
警报对话框支持文档方向。在对话框或父元素上设置 dir="rtl"。