Modal

Opinionated one-prop dialog for reversible flows — forms, invites, informational panels.

Modal is the common case of Dialog with zero composition: open + onOpenChange + title/description/footer slots and a width preset. It's for reversible flows — anything where dismissing by accident costs nothing. For destructive confirmations, use AlertDialog/ConfirmDialog instead (see the comparison below).

Installation

import { Modal } from "@iammikz/srui";

Usage

An invite flow — body content, a guarded primary action, and dismissal that can't lose anything:

Informational (size="sm")

One fact, one way out:

Props

PropTypeDefaultDescription
openboolean—Controlled open state
onOpenChange(open: boolean) => void—Close requests (Escape, overlay, ×)
titleReactNode—Heading (required for a11y)
descriptionReactNode—Muted subheading
childrenReactNode—Body
footerReactNode—Right-aligned action row
size"sm" | "md" | "lg" | "xl""md"Width preset
showCloseButtonbooleantrueHide the corner ×

Modal vs AlertDialog

They look alike; the contract differs. Pick by what an accidental dismissal would cost.

Modal (this)AlertDialog / ConfirmDialog
DismissalEscape, overlay click, corner × — all close itExplicit Action or Cancel only; overlay and Escape are ignored
Roledialogalertdialog (announced assertively)
Built forReversible flows: forms, invites, editors, infoIrreversible actions: delete, publish, charge
FooterAnything you passAction + Cancel; Action can be destructive
Losing inputAcceptable — nothing destructive happenedMust be impossible to click away from

Rule of thumb: if the primary button says Delete, Remove, or Publish, reach for AlertDialog. Everything else is a Modal. Need trigger composition or custom layout? Start from Dialog.

Accessibility

Everything Dialog provides: labelled dialog, focus trap, Escape and overlay dismissal with focus restoration.