Basic Usage
Props Reference
Component that opens the dialog when clicked
Dialog heading
Descriptive text below the title
Main dialog content
Controlled State
Whether dialog is open (controlled)
Initial open state (uncontrolled)
Event fired when dialog opens or closes
Event fired after animation completes
Modal Behavior
True: Locks scroll, traps focus, disables outside clicksFalse: Allows interaction with page'trap-focus': Only traps focus, allows scroll and outside clicks
Prevents closing by clicking outside the dialog
With Custom Content
Compositional API
For full control:Dialog Components
dialog.root
Container for all dialog parts.dialog.trigger
Button that opens the dialog.dialog.portal
Portals the dialog to document body.dialog.backdrop
Semi-transparent overlay behind dialog.dialog.popup
Main dialog container with content.CSS selector of element to focus when opened
CSS selector of element to focus when closed
dialog.title
Heading text (h2 element).dialog.description
Description text (p element).dialog.close
Button to close the dialog.Styling Classes
Access predefined styles viaui.dialog.class_names:
BACKDROP: Dark overlay with opacity transitionsPOPUP: Centered dialog box with shadow and borderTITLE: Large semibold headingDESCRIPTION: Secondary textHEADER: Header section with paddingCONTENT: Content area with paddingTRIGGER: Trigger element (empty by default)CLOSE: Close button (empty by default)
Animation
The dialog includes smooth enter/exit animations:- Backdrop fades in/out
- Popup scales from 90% to 100%
- 150ms duration for all transitions
Auto-Close Button
The high-level API includes a close button in the top-right corner:Portal Container
CSS selector for custom portal container (default: body)
Accessibility
- Focus trap when modal=True
- Escape key closes dialog
- ARIA labels and roles
- Keyboard navigation support
- Screen reader announcements
Implementation Details
From source code atreflex_ui/components/base/dialog.py:196:
- Built on Base UI Dialog primitives
- High-level wrapper creates complete structure
- Auto-includes backdrop and portal
- Close button with icon auto-added in header
- Positioned at center with negative margin for offset
- Width capped at 32rem with max-width for mobile