Dialog

Use Dialog for a focused task that needs a temporary surface over the current page.

Preview

Edit a profile

Open a dialog with name and username inputs, then dismiss it with Cancel or the illustrative Save button.

Open it to test the focus trap and Escape-to-close behavior.

Installation

New to this Registry? Complete the base setup before continuing.

npx shadcn@latest add @neumorphism-ui/dialog

Install the shared base once, then add components and their dependencies with the CLI.

Edit a profile

npx shadcn@latest add @neumorphism-ui/button @neumorphism-ui/dialog @neumorphism-ui/input @neumorphism-ui/label
Registry JSON

Usage

Compose DialogTrigger and DialogContent inside Dialog. Add a title and description, then use DialogClose for cancellation and an application handler for the main action.

"use client";

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

export default function Example() {
  return (
    <Dialog>
      <DialogTrigger render={<Button />}>Project details</DialogTrigger>
      <DialogContent>
        <DialogHeader>
          <DialogTitle>Team workspace</DialogTitle>
          <DialogDescription>Manage your projects in one place.</DialogDescription>
        </DialogHeader>
        <DialogFooter><DialogClose render={<Button />}>Close</DialogClose></DialogFooter>
      </DialogContent>
    </Dialog>
  );
}

API Reference

Built on Base UI Dialog to compose a Portal, Backdrop, Popup, title, description, and close actions. The primitive handles Escape, outside clicks, focus trapping, and focus restoration.

ComponentPropTypeDefaultDescription
Dialogopen / defaultOpenbooleanfalseThe controlled open state or initial uncontrolled open state.
DialogonOpenChange(open: boolean) => void—Called when the open state changes.
DialogmodalbooleantrueDetermines background interaction and focus-trap behavior.
DialogTrigger / DialogCloserenderReactElement | (props, state) => ReactElement—Composes trigger or close behavior onto a button or link.
DialogContentshowCloseButtonbooleantrueDisplays the default close button in the upper-right corner.
DialogContentoverlayClassNamestring | (state) => string—Extends the Backdrop color, blur, and transition independently.
DialogdisablePointerDismissalbooleanfalsePrevents an outside pointer press from closing Dialog.

Accessibility

  • 01

    Provide DialogTitle inside DialogContent and connect supporting copy with DialogDescription.

  • 02

    Base UI manages the modal focus trap, closing with Escape, and restoring focus to the trigger after close.

  • 03

    Wrap the cancel action in DialogFooter with DialogClose to provide an explicit close behavior.