Overview
The Dialog component provides a modal overlay that displays content above the main application. It captures focus and prevents interaction with the underlying content until dismissed.Components
The Dialog is composed of multiple subcomponents:- Dialog.Root - The main container that manages dialog state
- Dialog.Content - The dialog content area
- Dialog.Header - Optional header section
- Dialog.Body - Main content body
- Dialog.Footer - Optional footer section
- Dialog.Title - Dialog title element
- Dialog.Description - Dialog description element
- Dialog.CloseButton - Button to close the dialog
Basic Usage
Dialog.Root Props
Controls the open/closed state of the dialog. Can be bound with
bind:open.When true, disables dialog interactions.
Portal destination for rendering the dialog. Uses layer 1 by default.
Optional factory function to customize dialog bond creation.
HTML element type for the root element.
Animation function for the dialog root. Default uses
animateDialogRoot().Render function that receives the dialog bond instance.
Dialog.Content Props
Animation function for the content. Default uses
animateDialogContent().Animation function when content enters.
Animation function when content exits.
Initial animation state.
Dialog.Header Props
Extends standard HTML div attributes. Use for styling and layout of the header area.Dialog.Body Props
Extends standard HTML div attributes. Contains the main dialog content.Dialog.Footer Props
Extends standard HTML div attributes. Typically contains action buttons.Dialog.Title Props
HTML element type for the title.
Dialog.Description Props
HTML element type for the description.
Dialog.CloseButton Props
HTML element type for the close button.
Click handler. The dialog will close unless
event.preventDefault() is called.Animation Hooks
animateDialogRoot
Animates the dialog backdrop with opacity transition.duration(number): Animation duration in seconds. Default:DURATION.fast / 1000delay(number): Animation delay in seconds. Default:0ease(string): Easing function. Default:'anticipate'
animateDialogContent
Animates the dialog content with scale and opacity transitions.duration(number): Animation duration in seconds. Default:DURATION.fast / 1000delay(number): Animation delay in seconds. Default:0ease(string): Easing function. Default:'anticipate'
Examples
Dialog with Dropdown
Custom Backdrop
Accessibility
- Uses native
<dialog>element for semantic HTML - Automatically manages focus when opened
- Clicking the backdrop closes the dialog
- Escape key closes the dialog (native browser behavior)
- Close button includes default close icon