Modal
A flexible dialog component with backdrop, focus trap, and keyboard support.
Basic Usage
Danger Variant
Use the variant prop to change the modal's appearance for different contexts.
Sizes
Features
- Focus Trap - Keyboard focus is trapped within the modal
- Escape Key - Press Escape to close (configurable)
- Backdrop Click - Click outside to close (configurable)
- Portal - Renders at document body level
- Animations - Smooth enter/exit transitions
- Accessibility - Proper ARIA attributes and roles
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Controls modal visibility (bindable) |
title | string | '' | Modal title text |
size | 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'md' | Modal width |
variant | 'default' | 'danger' | 'warning' | 'success' | 'info' | 'default' | Color variant for icon container |
closeOnBackdrop | boolean | true | Close when clicking backdrop |
closeOnEscape | boolean | true | Close when pressing Escape |
showClose | boolean | true | Show close button |
children | Snippet | - | Modal body content |
footer | Snippet | - | Footer actions (buttons) |
icon | Snippet | - | Custom icon in header |
onclose | function | - | Called when modal closes |