Skip to Content
ComponentsModal

Modal

Compound modal dialog. Renders into a portal, closes on overlay click or Escape key. Supports controlled and uncontrolled state.

Preview

Anatomy

import { Modal } from '@wire-ui/react' <Modal.Root open={open} onOpenChange={setOpen}> <Modal.Portal> <Modal.Overlay> <Modal.Content> <h2>Dialog title</h2> <p>Dialog body</p> <Modal.Close>Close</Modal.Close> </Modal.Content> </Modal.Overlay> </Modal.Portal> </Modal.Root>

Root props

PropTypeDefaultDescription
openbooleanControlled open state
defaultOpenbooleanfalseInitial state for uncontrolled use
onOpenChange(open: boolean) => voidCalled when open state changes

Data attributes

data-state is set on both Modal.Overlay and Modal.Content:

ValueWhen
"open"Modal is open
"closed"Modal is closed

Behaviour

  • Portal — content is rendered outside the document tree via createPortal
  • Escape key — closes the modal
  • Overlay click — closes the modal
  • Modal.Content — renders with role="dialog" and aria-modal="true"
  • Modal.Close — any button inside that calls onOpenChange(false) on click

Animation

Use data-state with CSS transitions:

[data-state="open"] { animation: fadeIn 150ms ease; } [data-state="closed"] { animation: fadeOut 150ms ease; }
Last updated on

MIT License © 2026 wire-ui