Confirmation
Names the consequence before an irreversible action.
<Dialog>
<Dialog.Trigger asChild>
<Button variant="solid" tone="danger">Delete item</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Header>Blocks the page with one focused task the user must finish or dismiss.
import { Dialog } from "@/fragments/ui";Source<Dialog>
<Dialog.Trigger asChild>
<Button>Open dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Close />npx @usefragments/cli add dialogWrites src/fragments/ui/components/Dialog plus what it imports, the globals stylesheet, and .fragments/registry-lock.json, then prints the packages to add. No account, no key.
Your own registry: publish from Fragments Cloud and add --registry org/name. Connect a workspace.
Dialog is a compound: import the root and reach its parts through dot notation.
Dialog.TriggerDialog.ContentDialog.CloseDialog.HeaderDialog.TitleDialog.DescriptionDialog.BodyDialog.FooterHeader, body, and footer in the standard layout.
<Dialog>
<Dialog.Trigger asChild>
<Button>Open dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Close />
<Dialog.Header>
<Dialog.Title>Dialog title</Dialog.Title>
<Dialog.Description>Focused supporting content.</Dialog.Description>
</Dialog.Header>
<Dialog.Body>Dialog body</Dialog.Body>
<Dialog.Footer>
<Dialog.Close asChild>
<Button variant="soft">Close</Button>
</Dialog.Close>
</Dialog.Footer>
</Dialog.Content>
</Dialog>Names the consequence before an irreversible action.
<Dialog>
<Dialog.Trigger asChild>
<Button variant="solid" tone="danger">Delete item</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Header>Wider surface for denser content.
<Dialog>
<Dialog.Trigger asChild>
<Button>Open large dialog</Button>
</Dialog.Trigger>
<Dialog.Content width="lg">
<Dialog.Close />Skips autofocus when you place focus yourself.
<Dialog>
<Dialog.Trigger asChild>
<Button variant="soft">Open settings</Button>
</Dialog.Trigger>
<Dialog.Content initialFocus={false}>
<Dialog.Header>A wrapping title keeps the close control reachable.
<Dialog>
<Dialog.Trigger asChild>
<Button>Open long title dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Close />Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | node | Not set | — |
defaultOpen | boolean | Not set | Default open state |
modal | boolean | true | Whether the dialog blocks interaction with the rest of the page. |
onOpenChange | function | Not set | Called when open state changes |
open | boolean | Not set | Controlled open state |
Do not use a Dialog for a non-blocking notification.
Don’t
<Dialog>Saved</Dialog>Do
<Alert tone="success">
<Alert.Icon />
<Alert.Body>
<Alert.Title>Changes saved</Alert.Title>
<Alert.Content>Your settings are up to date.</Alert.Content>
</Alert.Body>
</Alert>Do not omit an accessible title and explicit close action from a Dialog.
Don’t
<Dialog><Dialog.Content>Focused task</Dialog.Content></Dialog>Do
<Dialog defaultOpen>
<Dialog.Content>
<Dialog.Title>Account settings</Dialog.Title>
<Dialog.Body>Update your workspace preferences.</Dialog.Body>
<Dialog.Close>Close</Dialog.Close>
</Dialog.Content>
</Dialog>