Components
Modal
Accessible dialog overlay with focus trap, keyboard dismissal, and configurable sizes.
Import
Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | — | Whether the modal is visible |
onClose | () => void | — | Called when user dismisses the modal |
title | string | — | Dialog title (sets aria-labelledby) |
description | string | — | Subtitle below title |
size | 'sm' | 'md' | 'lg' | 'xl' | 'full' | 'md' | Dialog width |
closeOnOverlayClick | boolean | true | Close when clicking backdrop |
closeOnEsc | boolean | true | Close on Escape key |
footer | React.ReactNode | — | Footer content (buttons) |
children | React.ReactNode | — | Dialog body |
className | string | — | Additional CSS classes on dialog |
Sizes
| Size | Max width |
|---|---|
sm | 400px |
md | 560px |
lg | 720px |
xl | 960px |
full | 100% screen |
No overlay close
Without title
When no title is provided, a close button still appears in the top-right corner. Add aria-label to describe the dialog purpose:
Accessibility
role="dialog"andaria-modal="true"on the dialog elementaria-labelledbypoints to the title element whentitleis providedaria-describedbypoints to the description when provided- Focus trap: Tab/Shift+Tab cycle only through focusable elements inside the dialog
- Focus returns to the triggering element when modal closes
Escapecloses the modal (configurable)- Prevents body scroll when open