对话框
用途
Add your dialog HTML
A3S UI uses the native <dialog> element and showModal(). This differs from shadcn/ui's portalled Base UI implementation, but preserves native modality, focus handling, and inert page content without component JavaScript.
HTML 结构
<button type="button" onclick="dialog.showModal()">Optional- Trigger button. A3S UI intentionally uses the native
HTMLDialogElement.showModal()method. <dialog class="dialog" id="{ DIALOG_ID }">Native modal dialog. Add
aria-labelledby="{ TITLE_ID }"andaria-describedby="{ DESCRIPTION_ID }"when title and description are present. Add width utilities to the inner<div>when a dialog needs a custom size. The macro also adds backdrop-click close handling.<div>Dialog content surface.
<header>OptionalDialog header.
<h2 id="{ TITLE_ID }">- Dialog title. Reference it from
aria-labelledby. <p id="{ DESCRIPTION_ID }">Optional- Dialog description. Reference it from
aria-describedby.
<section>Optional- Dialog body/content area. Add overflow utilities when the body should scroll.
<footer>Optional- Action area. It stacks actions on small screens and aligns them to the end on larger screens.
<button type="button" onclick="this.closest('dialog').close()">Optional- Close button. You can also wrap a button in
<form method="dialog">.
示例
自定义关闭按钮
无关闭按钮
粘页脚
可滚动内容
RTL
对话框定位和关闭按钮放置使用逻辑属性。在对话框或父元素上设置 dir="rtl"。