Accessible modal dialog with focus trapping, escape-to-close and focus restoration.

npx slipstream-ui@latest add dialog
Playground

Props

PropTypeDefaultDescription
openbooleanrequiredWhether the dialog is visible (controlled)
onOpenChange(open: boolean) => voidrequiredOpen/close requests
titlestringrequiredAccessible dialog name
descriptionstring—Optional supporting text
closeOnBackdropbooleantrueBackdrop click closes the dialog
initialFocusRefRefObject<HTMLElement>first focusableElement focused on open

Accessibility

  • role=dialog with aria-modal, labelled by title and described by description
  • Initial focus moves into the dialog and returns to the opener on close
  • Tab and Shift+Tab wrap inside the dialog
  • Escape closes the dialog