Modal

A dialog overlay that focuses user attention on a specific task or information, blocking interaction with the rest of the page.

Basic Modal

Sizes

Composable API

Non-dismissible Modal

Props

NameTypeDefaultDescription
size'sm' | 'md' | 'lg' | 'xl' | 'fullscreen''md'Size of the modal
titlestring-Modal title (convenience API)
descriptionstring-Modal description (convenience API)
dismissiblebooleantrueWhether modal shows close button
closeOnBackdropClickbooleantrueWhether clicking backdrop closes modal
closeOnEscapebooleantrueWhether pressing Escape closes modal
openboolean-Controlled open state
onOpenChange(open: boolean) => void-Open state change handler
children*ReactNode-Modal body content
footerReactNode-Modal footer content (convenience API)

Usage Guidelines

When to use

  • For critical information that requires immediate user attention and action
  • To confirm destructive actions before proceeding
  • To collect user input in a focused context
  • To display supplementary content without navigating away from the page

Best practices

  • Keep modal content concise and focused on a single task or message
  • Provide clear action buttons - users should know exactly what will happen
  • Use appropriate size - don't make modals larger than necessary
  • Allow dismissal via backdrop click and Escape key (unless critical)
  • Use non-dismissible modals sparingly, only for critical actions

Accessibility

  • ARIA role: dialog with proper aria-labelledby and aria-describedby
  • Focus trap: Focus is trapped within modal when open
  • Keyboard accessible: Escape to close, Tab to navigate
  • Focus management: Focus returns to trigger element on close
  • Portal rendering: Rendered at document body level for proper stacking

Do's and Don'ts

Do

  • Use descriptive titles that clearly explain the modal's purpose
  • Provide clear action buttons with explicit labels
  • Allow users to dismiss the modal easily (unless critical)
  • Use appropriate modal size based on content
  • Use non-dismissible modals only for critical actions
Good: Clear title, description, and action buttons

Don't

  • Don't use vague titles like "Attention" or "Notice"
  • Don't overload modals with too much content or multiple tasks
  • Don't nest modals (modal inside modal)
  • Don't use modals for complex workflows (use full pages instead)
  • Don't make non-critical modals non-dismissible
Bad: Vague title, oversized modal, non-dismissible for non-critical content

Related Components

Resources