Dialog
Styled dialog component family built on zw-dialog primitives.
@zeus-web/dialogFeedbackzweb add dialogGenerated
Playground
Source
Choose the framework entry that matches your application.
html
<script type="module">
import '@zeus-web/dialog/wc/auto'
</script>
<zw-dialog>
<zw-dialog-trigger>Open dialog</zw-dialog-trigger>
<zw-dialog-content>
<zw-dialog-title>Publish project?</zw-dialog-title>
<zw-dialog-description>
The project will become visible to everyone.
</zw-dialog-description>
<zw-dialog-close>Cancel</zw-dialog-close>
</zw-dialog-content>
</zw-dialog>tsx
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogTitle,
DialogTrigger,
} from '@zeus-web/dialog/react'
export function DialogExample() {
return (
<Dialog>
<DialogTrigger>Open dialog</DialogTrigger>
<DialogContent>
<DialogTitle>Publish project?</DialogTitle>
<DialogDescription>
The project will become visible to everyone.
</DialogDescription>
<DialogClose>Cancel</DialogClose>
</DialogContent>
</Dialog>
)
}vue
<script setup lang="ts">
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogTitle,
DialogTrigger,
} from '@zeus-web/dialog/vue'
</script>
<template>
<Dialog>
<DialogTrigger>Open dialog</DialogTrigger>
<DialogContent>
<DialogTitle>Publish project?</DialogTitle>
<DialogDescription>
The project will become visible to everyone.
</DialogDescription>
<DialogClose>Cancel</DialogClose>
</DialogContent>
</Dialog>
</template>Add
bash
zweb add dialogImports
Styled registry component:
tsx
import {
Dialog,
DialogTrigger,
DialogContent,
DialogTitle,
DialogDescription,
DialogClose,
} from '@/components/ui/dialog'Primitive React wrapper:
tsx
import {
Dialog,
DialogTrigger,
DialogContent,
DialogTitle,
DialogDescription,
DialogClose,
} from '@zeus-web/dialog/react'Web Component entry:
ts
import '@zeus-web/dialog/wc/auto'Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | Controlled open state. |
defaultOpen | boolean | - | Initial open state. |
modal | boolean | true | Whether the dialog is modal. |
Events
| Event | React prop | Detail | Description |
|---|---|---|---|
open-change | onOpenChange | open: boolean, nativeEvent?: Event | Emitted when open state changes. |
Slots
| Slot | Description |
|---|---|
default | Dialog child components. |
Styling
Uses Tailwind: yes
Theme tokens:
bg-backgroundtext-foregroundring-ring
Internal selectors:
[data-slot=dialog-content][data-slot=dialog-title][data-slot=dialog-description]
Registry
Registry source: available.
Add command: zweb add dialog
Type: component
Dependencies:
@zeus-web/dialog
Registry dependencies:
cnglobals
Files:
templates/react/dialog.tsx→components/ui/dialog.tsxtemplates/vue/dialog.ts→components/ui/dialog.ts
AI usage rules
Do:
- Use Dialog, DialogTrigger and DialogContent together.
- Use DialogTitle for accessible titles.
- Use DialogDescription when extra accessible context is available.
- Rely on the primitive for Escape close, focus return, and modal focus trapping.
Do not:
- Do not create a second overlay unless the registry provides one.
- Do not remove DialogTitle when the dialog needs an accessible name.
- Do not manually wire aria-labelledby or aria-describedby when using the provided title and description primitives.
Examples
React styled usage
tsx
import {
Dialog,
DialogContent,
DialogTitle,
DialogTrigger,
} from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
export function Example() {
return (
<Dialog>
<DialogTrigger>
<Button>Open</Button>
</DialogTrigger>
<DialogContent>
<DialogTitle>Title</DialogTitle>
</DialogContent>
</Dialog>
)
}