Overview
The Modal component displays content in a layer above the main application, blocking interaction with the underlying page until dismissed.Basic Usage
Sizes
Modals come in multiple sizes to accommodate different content needs:- Small
- Medium
- Large
- Full
Modal Structure
With Header, Body, and Footer
Close Behavior
Disable Outside Click
Disable Escape Key
Hide Close Button
Props
Modal Props
boolean
required
Controls whether the modal is visible
function
required
Callback function when modal should close:
() => voidstring
default:"md"
Modal size:
sm, md, lg, or fullboolean
default:"true"
Whether clicking the backdrop closes the modal
boolean
default:"true"
Whether pressing Escape closes the modal
boolean
default:"true"
Whether to show the X close button in the header
ReactNode
required
The content to display in the modal
string
Additional CSS class names to apply
string
CSS class names for the backdrop overlay
ModalHeader Props
ReactNode
required
Header content (typically a title)
ModalBody Props
ReactNode
required
Main modal content
ModalFooter Props
ReactNode
required
Footer content (typically action buttons)
string
default:"right"
Alignment of footer content:
left, center, or rightTypeScript Interfaces
Advanced Examples
Confirmation Modal
Form Modal
Modals automatically trap focus within them and restore focus when closed for better accessibility.
Accessibility
- Implements proper ARIA attributes (
role="dialog",aria-modal) - Traps focus within the modal while open
- Restores focus to trigger element on close
- Supports Escape key to close (configurable)
- Prevents body scroll when modal is open
- Screen reader compatible with proper announcements