Skip to content
GitHub (opens in a new tab)

Modal

Dismissible overlay for short tasks, forms or extra detail.

stableOrganismcontracts/modal.json

Preview

Modal

Dismissible overlay. Composes ModalCard. Not AlertDialog. Not Drawer.

Open the medium modal in the preview frame. The header has the eyebrow, description and Close; the footer has Ask on the left. Focus starts on the first field. Scrim click and Escape dismiss.

Usage

Use Modal for short forms and extra detail that can be dismissed. Use AlertDialog when they must choose. Use Drawer for an edge panel. Use ModalCard when you need the panel without an overlay. Product screens omit contained so Modal portals to the page.

Do's

  • Short forms
  • Extra detail
  • Command palettes
  • Anything that can be dismissed

Don'ts

<Modal
  open={open}
  eyebrow="Billing · Invoices"
  title="Edit invoice INV-2042"
  description="Change the due date or the amount."
  size="md"
  onClose={close}
  footerStart={<Button appearance="outline" mode="neutral" size="sm" iconStart="MessageCircle" onClick={ask}>Ask about this</Button>}
  footer={
    <>
      <Button appearance="outline" mode="neutral" size="sm" onClick={close}>Cancel</Button>
      <Button appearance="solid" mode="primary" size="sm" onClick={save}>Save changes</Button>
    </>
  }
>
  <Field label="Due date" htmlFor="due">
    <Input id="due" />
  </Field>
  <Field label="Amount" htmlFor="amount">
    <Input id="amount" />
  </Field>
</Modal>

Dismissible overlay for short tasks, forms, or extra detail. Composes ModalCard. Not a must-choose confirm.

  • Short forms
  • Extra detail
  • Command palettes
  • Anything that can be dismissed
  • Must-choose confirm — use AlertDialog
  • Inline status — use Alert
  • Side panel — use Drawer
  • Full-page — use a route
  • Panel without overlay — use ModalCard
  • Passive help — use Tooltip
import { Modal } from "agentic-ds-kit";
must
  • Composes ModalCard with role=dialog and aria-modal
  • Title (h2) is the accessible name, description is aria-describedby when present
  • Focus starts on the first field in the body, not Close; with no field the dialog itself takes focus
  • Focus is trapped while open and the page behind is inert
  • Escape closes, unless an open panel inside it (Select, DatePicker) handles that Escape first
  • Scrim click closes
  • Scroll lock keeps the scrollbar gutter, so the page does not shift
  • Focus returns to the opener on close; if the opener is gone, to the page heading (or main)
  • Unique ids via useId — do not hardcode modal-title
  • built-in labels (close, closeDialog) come from KitLabelsProvider; English by default
defaults
  • tone neutral
  • size md
  • showClose true
  • contained false
stops if
  • Do not invent local Dialog, Modal, DialogTrigger, or CommandDialog
  • Do not use raw hex
  • Do not use AlertDialog for dismissible work
  • Do not skip the close control unless showClose is false AND footer/body still provide a way out. Scrim click and Escape still close.

From contracts/modal.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

NameTypeRequiredDefaultNotes
openbooleanYes——
titlestringYes——
descriptionstringNo——
eyebrowstringNo—Short area name in the header row, 12px, like Billing · Invoices. Caller-provided.
toneenumNoneutralTone icon (16px, aria-hidden) and status word from KitLabels (info, success, warning, danger) before the eyebrow, so status is never colour alone. neutral shows the eyebrow only. neutral | info | success | warning | danger
sizesm | md | lgNomdsm 352 or md 448 for a short form, lg 576 to review a list. Below 480px (30rem) lg fills the screen.
showClosebooleanNotrue—
onClosefunctionYes——
childrenslotYes—Body
footerslotNo—kit Buttons / ButtonGroup, size sm: Cancel, then one primary last.
footerStartslotNo—Left of the footer actions, first in the footer tab order: an Ask Button (appearance outline, mode neutral, size sm, iconStart MessageCircle) or a count like 6 of 6 selected. Labels are caller-provided.
containedbooleanNofalseIn-canvas docs only. Product screens omit it (portal to document.body).
  • Component
    →

    AlertDialog

    Must-choose overlay that interrupts until the user cancels or confirms.

  • Component
    →

    Alert

    Inline status banner that stays on the page.

  • Component
    →

    Drawer

    Edge panel for secondary tasks.

  • Component
    →

    ModalCard

    The panel chrome for a modal: one shared header (tone icon + eyebrow, Close, h2 title, description) and footer (footerStart left, actions right).