Skip to main content

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:

Close Behavior

Disable Outside Click

Disable Escape Key

Hide Close Button

Props

boolean
required
Controls whether the modal is visible
function
required
Callback function when modal should close: () => void
string
default:"md"
Modal size: sm, md, lg, or full
boolean
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 right

TypeScript Interfaces

Advanced Examples

Confirmation Modal

Form Modal

Use the closeOnOutsideClick={false} prop for forms to prevent accidental data loss.
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