Dialog
打开用于编辑或确认的模态框。
用法
用于依赖当前页面上下文的操作,并提供关闭方法。
无障碍
提供 DialogTitle 和 DialogDescription,按 Escape 关闭后焦点回到触发器。
| 属性 | 类型 | 默认值 |
|---|---|---|
| open / defaultOpen | boolean | false |
| onOpenChange | (open: boolean) => void | None |
| theme (DialogContent) | light | dark | inherited |
| container (DialogContent) | HTMLElement | document.body |
<Dialog>
<DialogTrigger asChild><Button>Edit project</Button></DialogTrigger>
<DialogContent>
<DialogTitle>Project settings</DialogTitle>
<DialogDescription>Give your project a name.</DialogDescription>
<label htmlFor="name">Name</label>
<Input id="name" defaultValue="Interaction Inspector" />
<DialogClose asChild><Button>Done</Button></DialogClose>
</DialogContent>
</Dialog>