The Modal component creates a full-screen overlay with a slide-up animation from the bottom. It features automatic scroll locking, keyboard navigation, and click-outside-to-close functionality.
Prefer Dialog for dialogs
Add custom backdrop content behind the modal dialog using the backdrop prop.
The Modal component includes several built-in features:
- Smooth animations: Fade-in overlay with slide-up modal transition
- Scroll lock: Prevents body scrolling while modal is open
- Keyboard navigation: Press Escape to close
- Click outside: Click outside the modal to dismiss
- Auto-scroll reset: Content scrolls to top when modal opens
- Accessibility: role="dialog" and aria-modal="true" on the overlay
Modal does not currently contain focus: Tab from the last control inside it moves to the page behind, and focus is not returned to the trigger on close. aria-modal="true" tells a screen reader the rest of the page is inert, which is not yet enforced.
Until that is fixed, wrap the contents in a FocusTrap when the modal is a real modal step rather than an aside — or use Dialog, which traps focus and restores it.
- Modal slides up from the bottom with a 600ms ease transition
- Overlay fades in with a 300ms transition
- Close button is positioned in the top-right corner
- Content area is scrollable if it exceeds viewport height
- Modal is rendered in a portal to document.body