Skip to content
Theme
endue.ai

Components, Overlays

Modal

A dialog that floats above the screen, with a header, a body and a footer fixed at the bottom.

Name in code BaseModal

The modal is a dialog that floats above the screen. It has a header (title and close), a body, and a footer fixed at the bottom. The footer has one fill button. ConfirmDialog, RenameDialog and ChoiceDialog are built on top of it.

When to use

size Width Use
sm 420 Confirmations, short forms
md (default) 480 The default
lg 560 Forms
xl 720 Pickers
2xl 880 Usage and support shells
3xl 1120 Settings shell

height="tall" is fixed at 820px (settings, usage), and becomes full screen below 640px.

Anatomy

  • Scrim: overlay-scrim + 8px background blur, outer margin 16.
  • Box: card surface, 1px border, corner radius 12, shadow-lg. In dark, the surface takes the Stone tone.
  • Header: padding 16, 1px border below. The title is 16px, weight 600. Close is an IconButton md (icon 16).
  • Body: padding 16. When the content overflows, only the body scrolls. The description is 14px / 1.6 muted-foreground.
  • Footer: right aligned, 8 between buttons, padding 0 16 16. Buttons are BaseButton md.

Behavior

  • It closes with Esc, a click on the backdrop, or the close button. dismissible={false} turns off all three (re-authentication).
  • When it opens, focus moves inside and Tab cycles within it. When it closes, focus returns to the trigger.
  • When modals are stacked, only the top one responds to Esc.
  • onEscape gives Esc its own action when it should not close the modal. The Studio inspector steps back one level and closes only from the first one. The backdrop and the close button still close.
  • An editing screen opened from inside a dialog becomes one more step of that dialog, not a second modal. In the Studio inspector, DrillView takes the same props as the modal it replaces: the header shows the screen’s title with a back button, the body and the footer take the dialog’s body and bottom row, and the panel underneath stays mounted, so its search, tab and scroll are there when you step back. Outside a host dialog, DrillView is a plain modal.
  • Back, Esc and the breadcrumb ask the screen to close, so a screen with unsaved changes shows its confirmation first. The dialog’s close button and the backdrop ask the same question, and close the dialog if the changes are discarded.

What you provide

  • title: required. A confirmation dialog uses a question (“Delete this conversation?”).
  • description: what happens and whether it can be undone.
  • footer: cancel (outline) on the left, the confirming action (fill or danger) on the right. The confirming label is the name of the action (“Delete”). Don’t write “OK” or “Confirm”.
  • labelledBy: for a shell modal (header={false}) that draws its own title heading. Pass that heading’s id and the modal takes its name from it, instead of adding a second, hidden title.

Markup

<div class="BaseModal_backdrop">
  <div class="BaseModal_modal" style="max-width: 420px" role="dialog" aria-modal="true" aria-labelledby="t" aria-describedby="d" tabindex="-1">
    <header class="BaseModal_header">
      <h2 id="t" class="BaseModal_title">Delete this conversation?</h2>
      <button type="button" class="IconButton_btn IconButton_btn--ghost-muted IconButton_btn--md" aria-label="Close"><svg>…</svg></button>
    </header>
    <div class="BaseModal_body"><div id="d" class="BaseModal_description">…</div></div>
    <div class="BaseModal_footer">…</div>
  </div>
</div>

Set the width with an inline max-width. The header of a shell modal (settings) uses ModalShellHeader_header and ModalShellHeader_title.

Don’t

  • Don’t create new flows that stack a modal on top of a modal. An editing screen inside a dialog is a step of that dialog (DrillView). Only a confirmation may stack.
  • Don’t put more than three buttons in the footer.