Component guideEditable source

Dialog

A focused modal task with keyboard focus management.

Original component docs
On this page7 sectionsBack to top

Use Dialog for a focused task that interrupts the current page. Use Alert Dialog for consequential confirmation. DialogContent includes the portal and backdrop; do not add a second modal wrapper.

Live preview
Loading preview...

#Installation

Complete the base setup. For manual installation:

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/dialog.json

The live profile form additionally uses Input and Label. Install them before copying the Code. Its local save does not send a request. In an application, close only after an asynchronous operation succeeds and keep the dialog open on failure.

npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/input.json https://neobrutal-ui.andongmin.com/r/label.json

#Usage

import { Button } from "@/components/ui/button";
import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
} from "@/components/ui/dialog";

export default function WorkspaceDialog() {
  return (
    <Dialog>
      <DialogTrigger render={<Button />}>Workspace settings</DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Workspace settings</DialogTitle>
          <DialogDescription>Update preferences shared with your team.</DialogDescription>
        </DialogHeader>
        <p>Place the task controls here.</p>
      </DialogContent>
    </Dialog>
  );
}

#API reference

Prop / partPurposeDefault
Dialog.open / onOpenChangeControlled visibilityUncontrolled
Dialog.defaultOpenInitial visibilityfalse
DialogContent.showCloseButtonBuilt-in close controltrue
DialogFooter.showCloseButtonAdd a close button to the footerfalse
DialogContent.initialFocus / finalFocusFocus destinationsBase UI behavior
DialogTrigger.render / DialogClose.renderCompose with a buttonPrimitive element

#Accessibility

Keep a meaningful title and description. Tab and Shift+Tab stay in the modal; Escape closes a dismissible dialog. Verify that focus returns to its trigger. Do not remove the close control without providing another clear dismissal action. For longer tasks, keep actions reachable while the content scrolls.

DialogContent limits its height to the dynamic viewport minus 2rem and scrolls overflowing content by default. For a fixed header or footer, use the flex-column examples below: keep those sections shrink-0 and put min-h-0 overflow-y-auto on the body.

#Examples

#Scrollable content

Loading preview...
Loading preview...