Skip to Content
DocsEnterpriseBlogShowcase

Dialog

Used to display a dialog prompt

SourceStorybookRecipe

Setup

If you don't already have the snippet, run the following command to add the dialog snippet

chakra snippet add dialog

The snippet includes a closed component composition for the Dialog component.

Usage

import {
  DialogBody,
  DialogCloseTrigger,
  DialogContent,
  DialogFooter,
  DialogHeader,
  DialogRoot,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
<DialogRoot>
  <DialogBackdrop />
  <DialogTrigger />
  <DialogContent>
    <DialogCloseTrigger />
    <DialogHeader>
      <DialogTitle />
    </DialogHeader>
    <DialogBody />
    <DialogFooter />
  </DialogContent>
</DialogRoot>

Examples

Sizes

Use the size prop to change the size of the dialog component.

Centered

Use the centered prop to center the dialog component.

Controlled

Use the open and onOpenChange prop to control the visibility of the dialog component.

Initial Focus

Use the initialFocusEl prop to set the initial focus of the dialog component.

Inside Scroll

Use the scrollBehavior=inside prop to change the scroll behavior of the dialog when its content overflows.

Outside Scroll

Use the scrollBehavior=outside prop to change the scroll behavior of the dialog when its content overflows.

Motion Preset

Use the motionPreset prop to change the animation of the dialog component.

Alert Dialog

Set the role: "alertdialog" prop to change the dialog component to an alert dialog.

With DataList

Here's an example of how to compose the dialog component with the DataList component.