docs/components/dialog
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
A dialog for displaying content.
PreviewCode
Open
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/dialog
Dialog
├── DialogTrigger
└── DialogContent
├── DialogHeader
│ ├── DialogTitle
│ └── DialogDescription
├── DialogBody
└── DialogFooter
└── DialogClose
import {
Dialog,
DialogTrigger,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogBody,
DialogFooter,
DialogClose,
} from "@/components/ui/dialog";
<Dialog>
<DialogTrigger />
<DialogContent>
<DialogHeader>
<DialogTitle />
<DialogDescription />
</DialogHeader>
<DialogBody>
</DialogBody>
<DialogFooter>
<DialogClose />
</DialogFooter>
</DialogContent>
</Dialog>
Use open and onOpenChange on the root to control the dialog state.
PreviewCode
Open ControlledOpen Uncontrolled
DialogHeader supports two usage patterns:
Pass title and description props directly to DialogHeader.
<DialogHeader title="Dialog Title" description="Dialog description" />
This approach does not require
DialogTitleorDialogDescriptioncomponents.
Use DialogTitle and DialogDescription as children for more control.
<DialogHeader>
<DialogTitle>Dialog Title</DialogTitle>
<DialogDescription>Dialog description</DialogDescription>
</DialogHeader>
Use the size prop on DialogContent to control the maximum width of the panel.
PreviewCode
smmdlgxl2xl3xl4xl5xl6xlfullscreen
Use DialogBody to make the content area scrollable while keeping header and footer fixed.
PreviewCode
Open
Use the showCloseButton={false} prop to hide the close button in the top right corner.
PreviewCode
Open
Use closeOnInteractOutside and closeOnEscape props to prevent closing on outside click and escape.
PreviewCode
No close on outside clickNo close on Escape
Open a dialog imperatively from a menu item using the onSelect handler.
PreviewCode
Open
Use modal={false} to allow interaction with elements outside the dialog.
PreviewCode
Open
Use initialFocusEl to control which element receives focus when the dialog opens.
PreviewCode
Open
Nest dialogs within one another.
PreviewCode
Open
Use [--space:--spacing("value")] on DialogContent to adjust internal padding.
Default spacing is --spacing(6).
PreviewCode
Open
You can use breakpoint utilities to change the internal spacing at different screen sizes.
md:[--space:--spacing(6)] lg:[--space:--spacing(8)]
Root context provider. Controls open state and modal behavior.
| Prop | Type | Default |
|---|---|---|
open | boolean | - |
defaultOpen | boolean | false |
onOpenChange | ({ open }: OpenChangeDetails) => void | - |
modal | boolean | true |
closeOnEscape | boolean | true |
closeOnInteractOutside | boolean | true |
initialFocusEl | () => MaybeElement | - |
finalFocusEl | () => MaybeElement | - |
onEscapeKeyDown | (event: KeyboardEvent) => void | - |
onInteractOutside | (event: InteractOutsideEvent) => void | - |
className | string | - |
Opens the dialog on click. Use asChild for custom trigger elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
Holds the dialog panel. Supports size variants from sm to fullscreen.
| Prop | Type | Default |
|---|---|---|
size | `"sm" | "md" |
showCloseButton | boolean | true |
className | string | - |
| Attribute | Default |
|---|---|
--space | --spacing(6) |
Header area for title and description. Accepts props or children.
| Prop | Type | Default |
|---|---|---|
title | string | - |
description | string | - |
className | string | - |
Scrollable body content. Uses ScrollArea for overflow.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Footer area for action buttons.
| Prop | Type | Default |
|---|---|---|
className | string | - |
Accessible title for the dialog. Announced to screen readers.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
Accessible description for the dialog. Announced to screen readers.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
Closes the dialog on click. Use asChild for custom close elements.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
className | string | - |
Dimmed overlay behind the dialog panel.
| Prop | Type | Default |
|---|---|---|
className | string | - |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Date Picker ](/docs/components/date-picker)[
Next page
Drawer ](/docs/components/drawer)
On This Page
InstallationAnatomyUsageControlledTitle & DescriptionUsing propsUsing componentsSizeExamplesScrollableNo Close ButtonClose behaviorOpen from MenuNon-ModalInitial FocusNestedCustom spacingAPI ReferenceDialogDialogTriggerDialogContentDialogHeaderDialogBodyDialogFooterDialogTitleDialogDescriptionDialogCloseDialogOverlay