Documentation Index
Fetch the complete documentation index at: https://mintlify.com/RtlZeroMemory/Rezi/llms.txt
Use this file to discover all available pages before exploring further.
Modal Dialog Patterns
Patterns for creating modal dialogs, managing modal stacks, and building confirmation flows.Problem
You need to display:- Confirmation dialogs for destructive actions
- Forms or complex content in modal overlays
- Multiple modals stacked on top of each other
- Proper focus management and keyboard navigation
Solution
Useui.modal() for overlays, manage visibility with state, and use useModalStack for multiple modals.
Basic Confirmation Dialog
ui.layers([...])- Renders main content with modal on topbackdrop: "dim"- Darkens background contentonClose- Handles Escape key and close buttonreturnFocusTo- Restores focus to triggering element after close
Modal with Form
Modal Stack Management
For applications with multiple overlapping modals, useuseModalStack:
- LIFO ordering - Last opened modal is on top
- Automatic focus management - Focus moves between modals
modals.push(id, props)- Add modal to stackmodals.pop()- Remove top modalmodals.clear()- Close all modalsmodals.current()- Get ID of top modalmodals.size- Number of open modals
Dialog Helper Functions
Rezi provides pre-built dialog patterns:Confirmation Dialog
Alert Dialog
Prompt Dialog
Focus Management
Initial Focus
Set which element receives focus when modal opens:Return Focus
Restore focus to triggering element after modal closes:Focus Trap
Modals automatically trap focus - Tab/Shift+Tab cycles only through modal elements:Backdrop Styles
none- No backdrop (main content fully visible)dim- Semi-transparent dark overlay (default)blur- Blurred background effect
Modal Sizing
Keyboard Handling
Global Escape Handler
Modal-Specific Keys
Common Patterns
Confirmation Before Navigation
Multi-Step Modal Flow
Loading Modal
Best Practices
- Use
ui.layers([...])- Proper layering for modals - Always provide
onClose- Handle Escape key - Set
returnFocusTo- Restore focus after close - Use
initialFocusfor forms - Guide user to first input - Disable backdrop click to close for destructive actions - Use explicit buttons
- Keep modals focused - Don’t nest complex UIs unnecessarily
- Use
useModalStackfor multi-modal UIs - Automatic focus/stack management - Show clear action intent - Use
intentprop on buttons - Provide visual hierarchy - Primary action should stand out
- Test keyboard navigation - Tab, Shift+Tab, Escape, Enter
Related
- Button Widget - Modal actions
- Forms Recipe - Forms in modals
- Keyboard Shortcuts Recipe - Modal key handling
- Focus Management - Focus trap and navigation