Basic Modal

A minimal modal dialog with title, sizes, and action content.

Open in v0~1.3 kB

Last updated: March 7, 2026

Installation

npx smoothui-cli add basic-modal

Features

  • Controlled isOpen and onClose props
  • Title slot and fully custom body content
  • Size options for common layouts
  • Focus trap friendly and accessible structure
  • Composable action area

Accessibility

Keyboard Interactions

KeyDescription
EscapeCloses the modal
TabCycles focus through focusable elements within the modal (focus is trapped)
Shift + TabCycles focus backward through focusable elements within the modal

ARIA Attributes

AttributeElementPurpose
role="dialog"Modal containerIdentifies the element as a dialog
aria-modal="true"Modal containerIndicates the dialog is modal and content behind it is inert
aria-labelledbyModal containerReferences the modal title for an accessible name
aria-label="Close modal"Close buttonProvides an accessible name for the close button
aria-hidden="true"Close icon (X)Hides the decorative icon from screen readers

Screen Reader

  • Focus moves to the close button when the modal opens
  • Focus is trapped within the modal while open
  • Focus returns to the previously focused element when the modal closes
  • The modal title is announced via aria-labelledby

Reduced Motion

This component respects the prefers-reduced-motion media query via useReducedMotion from Motion. When reduced motion is preferred, backdrop fade, modal scale/slide entrance, and close button hover animations are disabled instantly.

Props