Dialog
Anatomy
Usage
Compose <Dialog>
, <DialogTrigger>
, and <DialogContent>
.
Widths
To set the width of the dialog, pass a className
to <DialogContent>
. Beneath 448px
, the buttons in the footer will stack vertically, with the primary button on top. There is no additional configuration required.
Without close button
A close button will display in the top right by default. To remove it, pass hideClose
to <DialogContent>
.
Scrolling
If the content of the dialog exceeds the height of the viewport, the dialog will scroll. If default scrolling interferes with other functionality or you want to implement your own scrolling, set scrollable
to false
.
Images
To add an image to the header of the dialog, pass an img
object containing src
and alt
to <DialogHeader>
.
API Reference
Dialog
The root dialog component.
Prop | Type | Default |
---|---|---|
defaultOpen | boolean | |
modal | boolean | true |
onOpenChange | (open: boolean) => void | |
open | boolean |
DialogTrigger
A component that triggers the dialog to open when clicked.
Inherits properties from HTMLButtonElement
.
Prop | Type | Default |
---|---|---|
asChild | boolean | |
children | ReactNode |
DialogContent
Contains content to be rendered in the open dialog.
Inherits properties from HTMLElement
.
Prop | Type | Default |
---|---|---|
children | ReactNode | |
className | string | |
scrollable | boolean | true |
DialogHeader
Displays a title, optional description, and a close button. Children will render to the left of the close button.
Inherits properties from HTMLDivElement
.
Prop | Type | Default |
---|---|---|
title | string | |
children | ReactNode | |
className | string | |
description | string | |
hideClose | boolean | |
img | { src: string; alt: string } |
DialogMain
A container for the main content of the dialog.
Inherits properties from HTMLDivElement
.
Prop | Type | Default |
---|---|---|
children | ReactNode |
DialogFooter
A container for the footer content of the dialog. Contains a primary action, an optional secondary action, and optional child elements. Elements display in a row on large dialogs, and a column on small dialogs.
Inherits properties from HTMLDivElement
.
Prop | Type | Default |
---|---|---|
primaryAction | ButtonProps | |
children | ReactNode | |
className | string | |
secondaryAction | ButtonProps |