Component docs

Modal

Native <dialog> that traps focus, restores it on close and dims the page.

When to use

  • Use for short, focused tasks that need a decision before continuing.
  • Always give a `title`; add `description` when the consequence needs explaining.
  • Put the primary action last in `footer`; keep Cancel available.

Playground

Change props on the right; the preview and code update instantly.

Delete project?

This removes all deployments. It can't be undone.

Body content goes here.
Props
<Modal open title="Delete project?" description="This removes all deployments. It can't be undone." size="md" dismissable />

Props

PropTypeDefaultDescription
openboolean—Controls visibility.
onClose() => void—Called on Escape, backdrop click or close button.
titlestring—Heading; labels the dialog.
descriptionstring—Supporting text; describes the dialog.
sizesm | md | lgmdMax width.
footerReactNode—Action row.
hideCloseButtonbooleanfalseHides the × button (keep another way out).
dismissablebooleantrueAllow Escape / backdrop to close.
childrenReactNode—Body content.

Keyboard navigation

KeysBehavior
Tab / Shift+TabCycle focus inside the dialog only.
EscapeClose (when dismissable).
Enter / SpaceActivate the focused button.
On closeFocus returns to the element that opened it.

ARIA attributes

AttributeGuidance
aria-labelledbySet automatically to the title.
aria-describedbySet automatically to the description when present.
aria-modalImplied by showModal(); content behind is inert.
aria-label (close)The × button is labelled “Close dialog”.

Theme tokens

Every part of Modal reads from these tokens, so it re-themes in light and dark automatically.

PartTokens
Panel
--surface-raised--border--radius-xl--shadow-lg--border-width
Backdrop
--overlay
Title
--font-display--text-h6--weight-semibold--tracking-tight
Description & body
--muted-foreground--foreground--text-sm--text-body
Footer
--surface--border--space-3--space-4--space-6
Close button
--muted--muted-foreground--radius-sm--space-8--target-min

Accessibility checklist

0 of 6 verified

Focus
Contrast
Target size
Keyboard
Screen reader

Check contrast numbers live on the Accessibility page.