★ GitHub
Component

Modal

A dialog overlay that captures focus and blocks interaction with the page behind it. Supports focus trapping, Escape to close, and body scroll lock.

Sizes

Usage

tsx
import { Modal, Button } from 'starkit-ui'; function Example() { const [open, setOpen] = useState(false); return ( <> <Button onClick={() => setOpen(true)}>Open Modal</Button> <Modal open={open} onClose={() => setOpen(false)} title="Confirm Action" footer={ <> <Button variant="ghost" onClick={() => setOpen(false)}>Cancel</Button> <Button variant="primary" onClick={() => setOpen(false)}>Confirm</Button> </> } > <p>Are you sure you want to proceed?</p> </Modal> </> ); }

Accessibility

  • Focus trap — Tab/Shift+Tab cycles within the modal
  • Escape — closes the modal
  • Body scroll lock — page cannot scroll while modal is open
  • Auto-focus — first focusable element is focused on open
  • Focus restore — previously focused element is restored on close

Props

PropTypeDefaultDescription
open *boolean—Whether the modal is visible
onClose *() => void—Called when the modal requests to close
titleReactNode—Header title text
size'sm' | 'md' | 'lg''md'Width preset
footerReactNode—Footer content (typically action buttons)
closeOnOverlaybooleantrueWhether clicking the overlay closes the modal