UI Component Examples/Patterns
Modal Pattern
Overlay dialog pattern composed from foundation components
Modal Pattern
Overview
The Modal pattern provides overlay dialogs for focused user interactions. It's composed from foundation components (Card, Button, Text) and handles backdrop interactions, animations, and accessibility.
GitHub Source: View the complete implementation in our repository.
Basic Usage
Modal Types
Basic modals display information with a close button.
Composition
The Modal pattern is composed from foundation components:
Advanced Features
Custom Animations
Nested Modals
Handle multiple modal layers:
Controlled Focus
Manage focus for accessibility:
Props API
| Prop | Type | Default | Description |
|---|---|---|---|
visible | boolean | required | Controls modal visibility |
onClose | () => void | required | Called when modal should close |
title | string | - | Modal header title |
children | ReactNode | - | Modal content |
primaryButton | ButtonProps | - | Primary action button |
secondaryButton | ButtonProps | - | Secondary action button |
fullScreen | boolean | false | Full screen presentation |
animationType | 'none' | 'slide' | 'fade' | 'fade' | Animation style |
backdropOpacity | number | 0.5 | Backdrop darkness (0-1) |
onShow | () => void | - | Called when modal appears |
Accessibility
Modal pattern includes comprehensive accessibility:
- Focus Management: Traps focus within modal
- Keyboard Navigation: Esc key closes modal
- Screen Reader: Announces modal presence
- Touch Outside: Closes modal (configurable)
Common Patterns
Confirmation Dialog
Loading Modal
Form Submission
Testing
Example tests for Modal pattern:
Related Patterns
- BottomSheet - Slide-up modal variant
- Dialog - Simple alert dialogs
- Drawer - Side navigation panel
Need help? Check the patterns-guide or ask in #ui-development channel.