Make your AI a shadcn expert

Shadcn Dialog

React dialog for profile forms, share sheets, and settings. Built with TypeScript and Tailwind CSS for Next.js using Base UI — focus trap and a required title.

A dialog sits over the page and makes everything else inert. Use it for a short form, a share link, or settings that need an answer before they go back. If they only pick yes or no, that is an Alert Dialog.

Scroll to load preview...

Looking for a neobrutalism version for shadcn?

Same dialog, thicker borders. The NeoBrutalism dialog is the kit if you want that look.

Usage

import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog"
<Dialog>
  <DialogTrigger>Open</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Edit profile</DialogTitle>
      <DialogDescription>
        This can&apos;t be undone. The account is deleted from the servers.
      </DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

Put render={<Button />} on the trigger so the Button is the actual control. DialogTitle is required — screen readers announce it when the overlay opens.

Composition

DialogTrigger
DialogTitle
DialogDescription

Custom Close Button

Replace the default X with DialogClose around your own button.

Scroll to load preview...

No Close Button

showCloseButton={false} hides the top-right X. Overlay click and Escape still dismiss it.

Scroll to load preview...

Keep DialogFooter outside the scroll region so Save stays on screen.

Scroll to load preview...

Scrollable Content

Put max-h-[50vh] overflow-y-auto on the body. The header stays put.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Header text and footer buttons follow the reading direction.

Scroll to load preview...

API

Prop

Type

DialogContent

Prop

Type

DialogFooter

Prop

Type

DialogTrigger and DialogClose take render.

Keyboard

KeyAction
Space / EnterOpen from the trigger, or fire the focused button
EscapeClose and return focus to the trigger
Tab / Shift + TabCycle controls inside the dialog

Focus stays in the overlay until it closes. Title and description are announced.

Notes

Hiding the X is not a lock

showCloseButton={false} still dismisses on overlay click and Escape. Prevent those events if they have to finish the form.

Name the action on the footer button. After it succeeds, a Sonner toast is enough.

With other components

Questions

Was this page helpful?

Sign in to leave feedback.