Dialog
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.
@neumorphism-ui/dialogPreview
Open it to test the focus trap and Escape-to-close behavior.
Installation
Installation: dialog
npx shadcn@latest add @neumorphism-ui/dialogThe CLI resolves npm dependencies, base tokens, utilities, and component source in order.
New to this Registry? Set up the namespace before continuing.
Usage
Usage: Installation
npx shadcn@latest add @neumorphism-ui/button @neumorphism-ui/dialogImport
Dialog import code
import { Button } from "@/components/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"Example
Dialog usage code
<Dialog>
<DialogTrigger render={<Button variant="primary" />}>
Create project
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>New project</DialogTitle>
<DialogDescription>
You can change the name and description later.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="soft" />}>Cancel</DialogClose>
<Button variant="primary">Create</Button>
</DialogFooter>
</DialogContent>
</Dialog>API Reference
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Dialog | open / defaultOpen | boolean | false | The controlled open state or initial uncontrolled open state. |
Dialog | onOpenChange | (open: boolean) => void | — | Called when the open state changes. |
Dialog | modal | boolean | true | Determines background interaction and focus-trap behavior. |
DialogTrigger / DialogClose | render | ReactElement | (props, state) => ReactElement | — | Composes trigger or close behavior onto a button or link. |
DialogContent | showCloseButton | boolean | true | Displays the default close button in the upper-right corner. |
DialogContent | overlayClassName | string | (state) => string | — | Extends the Backdrop color, blur, and transition independently. |
Dialog | disablePointerDismissal | boolean | false | Prevents 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.