Dialog Component
A modal dialog component that renders content in a layer above the page.
- Built on top of Radix UI's Dialog primitive
- Fully accessible with proper focus management
- Keyboard navigation and screen reader support
- Customizable with multiple parts for flexible layouts
Installation
The Dialog component is part of our UI library. You can import it directly from the components directory.
Usage
Here is how to use the dialog in your project.
React TSX
React TSX
Examples
Basic Dialog
React TSX
Form Dialog
React TSX
API Reference
Dialog Component Parts
The Dialog component is composed of several parts:
Component | Description |
---|---|
Dialog | The root component that manages the dialog state |
DialogTrigger | The button that opens the dialog |
DialogContent | The container for the dialog content |
DialogHeader | Container for the dialog title and description |
DialogTitle | The title displayed at the top of the dialog |
DialogDescription | The description text displayed below the title |
DialogFooter | Container for the dialog actions, typically at the bottom |
DialogClose | Button that closes the dialog |
Dialog Props
Prop | Type | Default | Description |
---|---|---|---|
open | boolean | - | Controls the open state of the dialog |
onOpenChange | (open: boolean) => void | - | Callback fired when the open state changes |
modal | boolean | true | Whether the dialog should block interactions with the rest of the app |
DialogContent Props
Prop | Type | Default | Description |
---|---|---|---|
forceMount | boolean | - | When used, dialog content will always render regardless of open state |
onEscapeKeyDown | (event: KeyboardEvent) => void | - | Event handler for escape key press |
onPointerDownOutside | (event: PointerDownOutsideEvent) => void | - | Event handler for clicks outside the dialog |
onInteractOutside | (event: React.MouseEvent | React.TouchEvent) => void | - | Event handler for interactions outside the dialog |
className | string | - | Additional CSS classes to apply to the dialog content |
Keyboard Interactions
Key | Description |
---|---|
Escape | Closes the dialog |
Tab | Focuses the next focusable element within the dialog |
Shift + Tab | Focuses the previous focusable element within the dialog |
</rewritten_file>