On this page

InstallationAnatomyEach part, and when it showsA header, a body and a footerWhat the title carriesThe XThe footer: three buttons at mostAt workSectionsThe line between two sectionsA section of textField groups in a sectionContent that pads itselfSizesTaller than the windowA form taller than the windowA form that submitsOpening itThree forms from the dashboardKeyboard and focusAccessibilityIn the dashboardAPI ReferenceModalModalContentModalSectionThe partsTokensRulesWritten downOpen questions

Modal

A card lifted over the page, which is covered and out of reach until the modal closes. A question with a yes and a no is its second piece, the Modal confirmation, which has its own page.

1<Modal open={open} onOpenChange={setOpen}>2  <ModalContent>3    <ModalHeader>4      <ModalTitle>Edit agent</ModalTitle>5      <ModalDescription>Change how this agent is named and what it may do.</ModalDescription>6    </ModalHeader>7    <ModalBody>8      <ModalSection>9        <Field title="Name">10          <Input defaultValue="Billing reconciler" />11        </Field>12      </ModalSection>13    </ModalBody>14    <ModalFooter>15      <ModalClose render={<Button>Cancel</Button>} />16      <Button color="primary" emphasis="high">17        Save18      </Button>19    </ModalFooter>20  </ModalContent>21</Modal>

Installation

import {
  Modal,
  ModalBody,
  ModalClose,
  ModalContent,
  ModalDescription,
  ModalFooter,
  ModalHeader,
  ModalSection,
  ModalTitle,
  ModalTrigger,
} from "@catalog-dashboard/components";

It is new. One screen draws it so far, the Probes page's Screenshot dialog. It is the design system's own (ds/components/modal.tsx), built on the primitives shadcn's Dialog and Alert Dialog use (Base UI's), with the Card's parts inside.

Anatomy

  1. 1 · The box. ModalContent: the card's fill, 12px corners, the deepest shadow.
  2. 2 · Title. The modal's name. 13px, medium, as a card's.
  3. 3 · Description. One line on what the modal is for.
  4. 4 · Body. What the modal holds, in sections. It pads nothing itself.
  5. 5 · Section. One group. It pads 12px above, 16px at its sides, and 16px under a control.
  6. 6 · Third button. Optional, at the left: a ghost.
  7. 7 · Second button. The neutral button, beside the main one.
  8. 8 · Main button. Always last, at the right.

Each part, and when it shows

PartWhat it isWhen it shows
The coverBlack at 40% over the whole page, 60% in dark. In the code it is the backdrop. A click on it closes the modal.Under an open modal.
ModalThe root. It draws nothing: it holds whether the modal is open.Never seen.
ModalContentThe box, centered in the window: the card's fill, 12px corners, the deepest of the four shadows. 384, 576 or 1024px wide.While the modal is open.
ModalHeaderThe top of the box, with a line under it. It pads 16px.When it is given. A modal with no title has no name for a screen reader, unless ModalContent is given an aria-label.
ModalTitleThe modal's name: 13px, medium. An icon before it, badges after it.In the header.
ModalDescriptionOne line under the title, in the secondary text color.When it is given.
The XA ghost button, 28px, over the header's top right corner. It closes the modal.Only with close. Off by default.
ModalBodyWhat the modal holds, in sections. It pads nothing itself. It scrolls when the modal is taller than the window.When it is given.
ModalSectionOne group in the body: a title (15px), a description, then fields, Field groups, a paragraph, anything, 16px apart. It pads 12px above, 16px at its sides, and 16px under a control or 12px under text. It can draw a line under itself.One for each group. A dialog with one group has one.
ModalFooterThe bottom of the box, with a line over it. Three buttons at most, 28px tall. The last two are at the right, 8px apart; the main one is last.When it is given.
The third buttonA ghost, at the footer's left edge. The footer puts it there itself.When the footer is given three buttons: it is the first of them.

A header, a body and a footer

The usual modal. The header holds the title and, under it, a description. The body holds the content in a section, which pads it: 16px from the sides and from the footer's line, 12px under the header's. The footer holds the buttons, at the right: the neutral button, then the primary button. The header draws a line under itself and the footer a line over itself. With a title alone the header is 52px tall, with a description 64px. The footer is 60px.

1<Modal open={open} onOpenChange={setOpen}>2  <ModalContent>3    <ModalHeader>4      <ModalTitle>Edit agent</ModalTitle>5      <ModalDescription>Change how this agent is named and what it may do.</ModalDescription>6    </ModalHeader>7    <ModalBody>8      <ModalSection>9        <Field title="Name">10          <Input defaultValue="Billing reconciler" />11        </Field>12        <Field title="Role">13          <Select defaultValue="editor">14            <SelectTrigger width="fixed">15              <SelectValue />16            </SelectTrigger>17            <SelectContent>18              <SelectItem value="admin">Admin</SelectItem>19              <SelectItem value="editor">Editor</SelectItem>20              <SelectItem value="viewer">Viewer</SelectItem>21            </SelectContent>22          </Select>23        </Field>24      </ModalSection>25    </ModalBody>26    <ModalFooter>27      <ModalClose render={<Button>Cancel</Button>} />28      <Button color="primary" emphasis="high">29        Save30      </Button>31    </ModalFooter>32  </ModalContent>33</Modal>

What the title carries

The title is the Card's title: 13px, medium. icon sits before it, in the secondary text color. badges takes one badge or several after it: a status, a tag, a tally. Give each size="md", 20px: a badge at its default size is 24px, and makes the header 4px taller. Only the title's text is the modal's name for a screen reader: the badges are not read as part of it.

1<ModalContent>2  <ModalHeader>3    <ModalTitle icon={Robot}>Edit agent</ModalTitle>4  </ModalHeader>5</ModalContent>6 7<ModalContent>8  <ModalHeader>9    <ModalTitle10      badges={11        <Badge color="info" size="md">12          Preview13        </Badge>14      }15    >16      Triggers17    </ModalTitle>18  </ModalHeader>19</ModalContent>20 21<ModalContent>22  <ModalHeader>23    <ModalTitle24      badges={25        <>26          <Badge size="md">3</Badge>27          <Badge color="success" size="md">28            Active29          </Badge>30        </>31      }32    >33      Members34    </ModalTitle>35    <ModalDescription>Everyone who can open this workspace.</ModalDescription>36  </ModalHeader>37</ModalContent>

The X

close on ModalContent adds a ghost X, 28px, that floats over the header's top right corner. It is off by default. The designer's brief: “Generally, if it has a footer, it won't have a close… but it's there as an option.” With a title alone the X has 12px above it, beside it and below it, the equal space rule 9 asks for. Under a title with a description the header is taller and the X stays in the corner: 12px above and beside, 24px below. The header keeps its text clear of it. With no header it sits over the body's corner. The X is the last stop of the Tab key, after the footer.

1<Modal open={open} onOpenChange={setOpen}>2  <ModalContent close>3    <ModalHeader>4      <ModalTitle icon={Key}>Signing key</ModalTitle>5    </ModalHeader>6    <ModalBody>7      <ModalSection ends="text">8        This key signs every token an agent presents. Rotating it signs new tokens with a new key.9      </ModalSection>10    </ModalBody>11  </ModalContent>12</Modal>

The footer: three buttons at most

The footer holds three buttons at most. The last two are at the right: the neutral button, then the main one, which is always last. A third, written first, lands on the left: a ghost, for an action beside the main choice, such as a reset. The footer places it itself. ModalClose makes any button close the modal. Footer buttons are 28px tall, the Card's limit for a header and a footer: one asked for at medium is drawn small. Controls in the body are not held to that: they are the size they ask for, 32px by default.

1<Modal open={open} onOpenChange={setOpen}>2  <ModalContent>3    <ModalHeader>4      <ModalTitle>Filter runs</ModalTitle>5    </ModalHeader>6    <ModalBody>7      <ModalSection>8        <Field title="Role">9          <Select defaultValue="editor">…</Select>10        </Field>11      </ModalSection>12    </ModalBody>13    <ModalFooter>14      <Button emphasis="ghost">Reset</Button>15      <ModalClose render={<Button>Cancel</Button>} />16      <Button color="primary" emphasis="high">17        Apply18      </Button>19    </ModalFooter>20  </ModalContent>21</Modal>

At work

While the modal's request runs, the main button takes the Button's own loading, with loadingPlacement="before": the Loader, then the word, with no “…” after it. It does not fire again. The screen disables the button beside it. The modal has no state of its own for this: both are the Button's props.

1<ModalFooter>2  <ModalClose render={<Button disabled={saving}>Cancel</Button>} />3  <Button color="primary" emphasis="high" loading={saving} loadingPlacement="before">4    {saving ? "Saving" : "Save"}5  </Button>6</ModalFooter>

Sections

The body pads nothing. What it holds is in sections, and a section pads itself. A ModalSection is one group. It can have a title (15px, text-label-1, a step over a field's title) and a description under it. Then it holds whatever the group needs: fields, any number of Field groups, a paragraph, an alert. What it holds starts 12px under the title (under the description, when it has one) and is stacked 16px apart. It pads 12px above, 16px at its sides, and under it what its last thing needs: 16px after a control (an input, a button, anything with a box), 12px after text. It cannot see what it ends with, so it is told: ends="text" for a section that ends with a paragraph; control is the default. A dialog with one group is one section; its title is optional there, since the modal's title already names it. The designer's word on a form of two sections: each has a title.

1<ModalContent>2  <ModalHeader>3    <ModalTitle>Edit agent</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <ModalSection title="Agent" line="full">7      <Field title="Name">8        <Input defaultValue="Billing reconciler" />9      </Field>10      <Field title="Role">11        <Select defaultValue="editor">…</Select>12      </Field>13    </ModalSection>14    <ModalSection title="Owner" description="Who is asked when this agent needs a decision.">15      <Field title="Team">16        <Input defaultValue="finance-ops" />17      </Field>18    </ModalSection>19  </ModalBody>20  <ModalFooter>21    <ModalClose render={<Button>Cancel</Button>} />22    <Button color="primary" emphasis="high">23      Save24    </Button>25  </ModalFooter>26</ModalContent>

The line between two sections

A section can draw a line under itself, before the next one. line="full" runs from edge to edge of the modal. line="inset" stops 16px from each side. With no line the two sections are apart by their padding alone. The last section in a body draws no line, whatever it is told: the footer has its own. Here the first section ends with text, so it pads 12px under it.

1<ModalContent>2  <ModalHeader>3    <ModalTitle>Rotate signing key</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <ModalSection title="What it does" ends="text" line="inset">7      <p className="text-neutral-fg-secondary">This key signs every token an agent presents.</p>8    </ModalSection>9    <ModalSection title="The new key">10      <Field title="Name">11        <Input defaultValue="Signing key 2" />12      </Field>13    </ModalSection>14  </ModalBody>15  <ModalFooter>16    <ModalClose render={<Button>Cancel</Button>} />17    <Button color="primary" emphasis="high">18      Save19    </Button>20  </ModalFooter>21</ModalContent>

A section of text

A section can hold a title and a paragraph and nothing to fill. It ends with text, so it says ends="text" and pads 12px under it: a line of text is empty under its baseline, so its letters then sit about 16px from the footer's line, as a control's edge would.

1<ModalContent>2  <ModalHeader>3    <ModalTitle>Rotate signing key</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <ModalSection title="Before you rotate" ends="text">7      <p className="text-neutral-fg-secondary">8        Tokens already issued stay valid until they expire. New tokens are signed with the new key from the next call.9      </p>10    </ModalSection>11  </ModalBody>12  <ModalFooter>13    <ModalClose render={<Button>Cancel</Button>} />14    <Button color="primary" emphasis="high">15      Rotate16    </Button>17  </ModalFooter>18</ModalContent>

Field groups in a section

A section holds as many Field groups as the form needs, each with its own title and as many fields as it needs, and anything between two of them: here a paragraph. A FieldGroup is the design system's own (title, description, a switch); the section only stacks what it is given. A form needs no part of its own: a <form className="contents"> inside ModalContent, around the header, the body and the footer, submits (see “A form that submits”).

1<ModalContent size="md">2  <ModalHeader>3    <ModalTitle>Edit agent</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <ModalSection title="Access" line="full">7      <FieldGroup title="Who can call it">8        <Field title="Team">9          <Input defaultValue="finance-ops" />10        </Field>11        <Field title="Role">12          <Select defaultValue="editor">…</Select>13        </Field>14      </FieldGroup>15      <p className="text-neutral-fg-secondary">A caller needs both: a team it belongs to, and a role on this agent.</p>16      <FieldGroup title="When it can run">17        <Field title="Days">18          <Input defaultValue="Monday to Friday" />19        </Field>20        <Field title="Hours">21          <Input defaultValue="8 AM to 6 PM" />22        </Field>23      </FieldGroup>24    </ModalSection>25    <ModalSection title="Limits">26      <Field title="Runs a day">27        <Input defaultValue="200" inputMode="numeric" />28      </Field>29    </ModalSection>30  </ModalBody>31  <ModalFooter>32    <ModalClose render={<Button>Cancel</Button>} />33    <Button color="primary" emphasis="high">34      Save35    </Button>36  </ModalFooter>37</ModalContent>

Content that pads itself

Content that brings its own padding is not a section: setting rows (a Field group with orientation="horizontal", whose rows pad themselves; a vertical one does not, and goes in a section) and the ds Table. It goes in the body as it is and runs from edge to edge. A picture brings no padding and is not a section either: the screen pads it, the card inset on all four sides (p-card-inset), as the Probes page's Screenshot dialog does.

1<ModalContent size="md">2  <ModalHeader>3    <ModalTitle>Notifications</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <FieldGroup orientation="horizontal" title="Email me when">7      <Field title="A run fails" description="One email per failed run.">8        <Switch defaultChecked aria-label="A run fails" />9      </Field>10      <Field title="A quota is reached" description="When an agent uses all of its allowance.">11        <Switch defaultChecked aria-label="A quota is reached" />12      </Field>13      <Field title="A key is about to expire" description="Seven days before.">14        <Switch aria-label="A key is about to expire" />15      </Field>16    </FieldGroup>17  </ModalBody>18  <ModalFooter>19    <ModalClose render={<Button color="primary" emphasis="high">Done</Button>} />20  </ModalFooter>21</ModalContent>

Sizes

size is the modal's width: sm 384px, the default, md 576px, lg 1024px. A modal is never wider than the window less 16px on each side. This column is 560px wide, so the md one here is drawn narrower than it is, and the lg one is not drawn at all: open them to see them at their size.

1<ModalContent size="sm">…</ModalContent>2<ModalContent size="md">…</ModalContent>3<ModalContent size="lg">…</ModalContent>

Taller than the window

A modal is as tall as its content, never taller than the window less 32px above and below, and never taller than 640px on a tall screen (--modal-max-height). When its content is taller, the body scrolls, and the header and the footer stay in place. It scrolls in the Scroll area: the thumb (6px, 4px in) shows under the pointer or while it scrolls, and a cover, 30px, lies over each edge the content runs on past, and only there. The body is then a stop of the Tab key, so the keyboard can scroll it. Running text, as here, ends where the room ends: the cover says there is more. The box here is 352px tall, as a short window would be.

1<ModalContent size="md">2  <ModalHeader>3    <ModalTitle badges={<Badge size="md">6</Badge>}>Glossary</ModalTitle>4    <ModalDescription>The words this product uses.</ModalDescription>5  </ModalHeader>6  <ModalBody>7    <ModalSection ends="text">8      <div className="flex flex-col gap-3 text-neutral-fg-secondary">…six paragraphs…</div>9    </ModalSection>10  </ModalBody>11  <ModalFooter>12    <ModalClose render={<Button>Close</Button>} />13  </ModalFooter>14</ModalContent>

A form taller than the window

A body of fields that overflows is trimmed so that its last row in view is cut part-way, two thirds of it showing: a row that ends under the cover says there is more below. A row is a part of a Field (its title, its description, its control) or a table's row. The body is made that much shorter, so the modal is too. cutRow on the body is that share, a number from 0 to 1 (2 / 3 by default), or false for no trimming. The box here is 288px tall.

1<ModalContent>2  <ModalHeader>3    <ModalTitle>Edit agent</ModalTitle>4  </ModalHeader>5  <ModalBody>6    <ModalSection>…three fields…</ModalSection>7  </ModalBody>8  <ModalFooter>9    <ModalClose render={<Button>Cancel</Button>} />10    <Button color="primary" emphasis="high">11      Save12    </Button>13  </ModalFooter>14</ModalContent>

A form that submits

A form's fields are in the body and its submit button is in the footer. One <form> goes around both. It is given the class contents, so it draws no box of its own and the modal keeps its layout. The Enter key in a field then submits, and the browser checks a required field first. The screen closes the modal itself once the form is sent. Closing a modal removes what is in it: what was typed is gone when it opens again, unless the screen keeps it.

Nothing submitted yet.
1<Modal open={open} onOpenChange={setOpen}>2  <ModalContent>3    <form4      className="contents"5      onSubmit={(event) => {6        event.preventDefault();7        addFile(new FormData(event.currentTarget).get("file"));8        setOpen(false);9      }}10    >11      <ModalHeader>12        <ModalTitle>New Cedar file</ModalTitle>13      </ModalHeader>14      <ModalBody>15        <ModalSection>16          <Field title="File name" description="The .cedar extension is added if missing.">17            <Input name="file" placeholder="my-rules.cedar" required />18          </Field>19        </ModalSection>20      </ModalBody>21      <ModalFooter>22        <ModalClose render={<Button type="button">Cancel</Button>} />23        <Button type="submit" color="primary" emphasis="high">24          Add25        </Button>26      </ModalFooter>27    </form>28  </ModalContent>29</Modal>

Opening it

ModalTrigger makes a button open the modal, and the modal keeps track of being open itself. A screen that opens it from somewhere else (a menu's row, the end of a request) decides that itself: it passes open and onOpenChange. When the modal closes, the focus goes back to what opened it.

1<Modal>2  <ModalTrigger render={<Button>Edit agent</Button>} />3  <ModalContent>4    <ModalHeader>5      <ModalTitle>Edit agent</ModalTitle>6    </ModalHeader>7    <ModalBody>8      <ModalSection>9        <Field title="Name">10          <Input defaultValue="Billing reconciler" />11        </Field>12      </ModalSection>13    </ModalBody>14    <ModalFooter>15      <ModalClose render={<Button>Cancel</Button>} />16      <Button color="primary" emphasis="high">17        Save18      </Button>19    </ModalFooter>20  </ModalContent>21</Modal>22 23<Button onClick={() => setOpen(true)}>Rename agent</Button>24<Modal open={open} onOpenChange={setOpen}>25  <ModalContent>26    <ModalHeader>27      <ModalTitle>Rename agent</ModalTitle>28    </ModalHeader>29    <ModalBody>30      <ModalSection>31        <Field title="Name">32          <Input defaultValue="Billing reconciler" />33        </Field>34      </ModalSection>35    </ModalBody>36    <ModalFooter>37      <ModalClose render={<Button>Cancel</Button>} />38      <Button color="primary" emphasis="high">39        Save40      </Button>41    </ModalFooter>42  </ModalContent>43</Modal>

Three forms from the dashboard

Three forms that live in dialogs today, drawn again in the Modal with the Field, the Input and the Select. They are pictures of what a move would give: the screens themselves are not changed. Whether a form belongs in a modal at all is the first open question.

New Cedar file

One field. Today the sentence about the extension is the dialog's description. Here it is the field's own, under its title, and the dialog's X is gone: Cancel is the way out.

components/rules/rule-editor.tsx

Add quota

Four fields, two of them side by side. Today the unit is written in the limit's label, “Limit (Model tokens)”. Here it is in the field, after the number. Today Cancel is a ghost button here and an outlined one elsewhere: here it is the neutral button, as in every modal.

components/quotas/allowances-view.tsx

Create agent API key, then the key

Two steps. The first asks for a name and a gateway. The second shows the key once. Today the second is a wider dialog with an X, and a click outside it loses the key. Here it has no X, a click on the cover does not close it (disablePointerDismissal), and the key's field copies it. The Escape key still closes it. Its warning is the field's description until the Alert is in the design system.

components/agents/agent-keys-card.tsx

Keyboard and focus

Measured in a browser, on the real modal.

KeyDoes
Enter, SpaceOn the button that opens it: opens the modal.
(on opening)The focus goes to the first control in the modal: the first field of a form, also when the body scrolls; the X when there is nothing else. Measured with a mouse and a keyboard, not on a touch screen.
TabThe next control. After the last one it goes back to the first: the focus stays in the modal. The X is last, after the footer.
Shift + TabThe previous control, and from the first one to the last.
EscapeCloses it. The focus goes back to what opened it.
EnterIn a field of a form: submits it, when the form is written as in “A form that submits”.

While a modal is open, the page behind does not scroll and does not answer the pointer. A click on the cover closes the modal.

A Select opened in a modal draws its menu over the modal. The Escape key then closes the menu, and the modal stays open: a second press closes the modal. A modal opened over another modal was not tried.

Closing a modal removes what is in it. A click on the cover closes a Modal with a half-filled form, and what was typed is gone. disablePointerDismissal on Modal stops the cover from closing it. The Escape key still does.

Accessibility

A screen reader is told that a Modal is a dialog (the role dialog). It reads the title as the modal's name, and the description after it. The title is a level-2 heading. A badge beside the title is not part of the name.

While one is open the rest of the page is hidden from a screen reader. The X is named “Close”. A body that scrolls is a stop of the Tab key, so the keyboard can scroll it.

In the dashboard a modal opens and closes in 150ms: the cover fades, and the box fades and grows from 95% of its size, out of the point that was pressed to open it, and shrinks back toward it as it closes. Opened from the keyboard, it grows from its own center. With reduced motion both only fade. The playground's “Open from” puts its button at the top right, the top, the bottom, the left or the center, to try it. What a screen reader says when one opens was not tested.

In the dashboard

One screen draws the Modal so far: the Probes page's Screenshot dialog (app/(authenticated)/[kind]/[scopeId]/probes/_components/browser-failure.tsx). This is what the rest of the dashboard draws today in its place, and what stays as it is.

Dialogs

35 dialogs in 30 files draw the older Dialog: a title, a body and buttons. All but the command palette have an X. Their title is 13px medium, as here, and their footer buttons are 32px.

components/ui/dialog.tsx

Side panels

A create or an edit form is a panel at the right of the page, which is not a modal: the page stays in reach. The Modal does not replace it.

components/ui/detail-panel.tsx

API Reference

Modal

The root. It draws nothing itself. Besides these, every prop of Base UI's Dialog root.

PropTypeDefaultDescription
openboolean—Whether it is open, when the screen holds that itself.
onOpenChange(open, details) => void—Called when it asks to open or to close: its trigger, the Escape key, a click on the cover, the X, a ModalClose. details.reason says which.
defaultOpenbooleanfalseOpen from the start, when the modal holds its own state.
disablePointerDismissalbooleanfalseA click on the cover no longer closes it. For a modal that shows something once, such as a new key. Base UI's own prop.

ModalContent

The box, and the cover behind it. Besides these, every prop of Base UI's Dialog popup.

PropTypeDefaultDescription
size"sm" | "md" | "lg""sm"The width: 384, 576 or 1024px.
closebooleanfalseAdds the X over the header's top right corner.

ModalSection

One group in the body, and the part that pads. A section element, named by its title. Its children are stacked 16px apart. Besides these, every prop of a section.

PropTypeDefaultDescription
titleReactNode—The group's name, over what it holds: 15px (text-label-1), a level-3 heading. A section alone in a modal needs none.
descriptionReactNode—A line under the title, in the secondary text.
ends"control" | "text""control"What its last thing is, which sets the padding under it: 16px after a control (an input, a button, anything with a box), 12px after text.
line"full" | "inset"—A line under the section, before the next one: from edge to edge of the modal, or 16px in from each side. Not on the last section: the footer draws its own.

The parts

The header, the title, the description, the body and the footer are the Card's parts under the Modal's names, and take what those take, with one exception: ModalBody takes no padding and no scroll. It pads nothing and always scrolls when its content is taller than its room.

PartWhat it isIts own props
ModalTriggerMakes a button open the modal.render: the button.
ModalHeaderThe Card's header.padding, the same six steps, md by default.
ModalTitleThe Card's title, and the modal's name.icon; badges: one badge or several. No switch and no count: a tally is a badge.
ModalDescriptionThe Card's description, and what a screen reader reads after the name.icon.
ModalBodyThe Card's content, with no padding, in the Scroll area.scrollArea (ScrollAreaSettings, the type the Table's takes): the scroll area's look, over the Modal's own (MODAL_SCROLL_AREA). cutRow (number | false): how much of the last row in view shows where the body overflows, from 0 to 1, two thirds by default (MODAL_CUT_SHARE); false for no trimming. Its other props, className included, go to the content and not to the box that scrolls: a height set there does nothing.
ModalSectionA section element, named by its title.See ModalSection above: title, description, ends, line.
ModalFooterThe Card's footer, for three buttons at most. Its last two children are at the right, and a third, written first, at the left.padding, md by default.
ModalCloseMakes a button close the modal.render: the button.
ModalPreviewDraws the modals inside it in place, open, with no cover. This page and the playground use it. A screen never does.container: the box to draw in.

Tokens

In ds/tokens/modal.css. The inset is the Card's own token (--card-inset), and the lines are the border color (--border).

TokenValueWhat it sets
--modal-backgroundThe card's fillThe modal's fill.
--modal-shadowStacking level 4The modal's edge and shadows: a 1px ring over two large drops. In dark the ring is the card's own.
--modal-backdropBlack at 40%, 60% in darkThe cover over the page (the backdrop).
--modal-section-inset-topThe card's text inset, 12pxAbove what a section holds.
--modal-section-inset-bottomThe card inset, 16pxUnder a section that ends with a control.
--modal-section-inset-bottom-textThe card's text inset, 12pxUnder a section that ends with text.
--modal-width-sm384pxThe width of sm, and of the Modal confirmation.
--modal-width-md576pxThe width of md.
--modal-width-lg1024pxThe width of lg.

Rules

Written down

A dialog is for one verb and one outcome

The written rule keeps a dialog for a yes or no before something that cannot be undone, and for one field, such as a quick rename. It sends creating or editing a thing to a side panel or a page, where the list behind stays in view. The first open question asks how that fits forms in a modal.

From design/principles.md (Dialogs vs Sheets vs Detail Panel).

The main button is at the right, Cancel at its left

The submit button sits in the footer, at the right. Cancel or Close is the button at its left.

From design/principles.md (Forms).

A component that holds another passes it through

The footer's buttons are the screen's own Buttons, written as its children. The Modal has no prop for a button's color, its icon or its loading: those are the Button's.

From ui/ds/README.md (Components).

A button shows its own loading while its request runs

A main button at work is the Button's loading, set by the screen.

From .claude/rules/dashboard-ui.md (rule 6).

A header and a footer hold controls of 28px at most

The Modal's header and footer are the Card's, so they follow the Card's rule: 16px on every side, and controls no taller than 28px. The second open question asks whether a modal's buttons should be the exception.

From .claude/rules/dashboard-ui.md (rule 8), written for the Card.

A box that scrolls is the Scroll area

The body scrolls in the ds Scroll area, with no scrolling box of its own: its thumb, its cover over each edge the content runs on past, and, for a body of fields or table rows, a last row with two thirds of it in view.

From .claude/rules/dashboard-ui.md (rule 5).

A section pads 12px above what it holds, and under it what its last thing needs

Rule 8 gives a row 12px around text and 16px around a control. A section is a group, not a row, so each of its edges takes the value for what meets it: 12px above, where a section starts with a line of text; under it 16px for a control, 12px for text. The body itself pads nothing. A section that starts with something else is the open question below.

From ui/ds/README.md (Modal); .claude/rules/dashboard-ui.md (rule 8), written for a card's rows.

A control at a box's edge has equal space around it

Under a title alone the X has 12px above it, beside it and below it. Under a title with a description the header is 12px taller and the X stays in the corner, so it has 24px below it: there the rule does not hold.

From .claude/rules/dashboard-ui.md (rule 9).

It opens and closes in 150ms, with a zoom and a fade

The cover fades. The box fades and grows from 95% of its size, out of the point that was pressed to open it, and closes back toward it; from the keyboard it grows from its center. With reduced motion both only fade. Measured with the dashboard's stylesheet, not on this page.

From design/principles.md (Motion).

The keyboard reaches everything the mouse reaches

Every control in a modal is a stop of the Tab key, and the Escape key closes it.

From design/principles.md (Interaction & Accessibility).

Open questions

Which forms may be a Modal?

Open
One field: a dialog, by the written rule
Four fields that create a thing: a side panel, by the written rule
The written rule

design/principles.md keeps a dialog for a yes or no and for one field. It sends creating or editing a thing to a side panel, and names creating an API key as one.

Your words

“Inside is going to be forms and stuff.” Eleven of today's 35 dialogs are forms, the three drawn above among them.

Are the footer's buttons 28px, as in a card, or 32px?

Open
Built: 28px
Your Modal page: 32px
Built

28px: the footer is the Card's, and a card's footer holds small controls. A confirmation's two buttons are 28px too.

Your Modal page

32px, in the Modal and in the confirmation. Today's dialogs also draw 32px buttons.

The title and the footer are the Card's, as you asked: your Modal page draws them differently, so is that still right?

Open
Built: a 13px title, one white box, a line over the footer
Your Modal page: a 17px title, the header and the body on a raised white panel, a gray footer
Built

“You copy the title” of the Card: 13px medium, over a 13px description. A separator under the header and one over the footer, on the card's fill: one white box.

Your Modal page

A 17px medium title over a 12px description, in a header that pads 20px at the sides. The header and the body sit on a white panel with its own soft shadow, and the footer is on the gray box around it, with no line.

Should the modal have a row for an error, over the footer?

Open
Built: no row. An error is under its field.
Your Modal page: a 40px row over the footer
Built

Not built. An error about one field shows under that field, which the Field already does. An error about the whole request has no place in the modal: the screen shows a toast.

Your Modal page

Two props, error-message and error-footer: a 40px row with an icon and a 12px sentence, over the footer. The confirmation has one too.

Are they Modal and Modal confirmation, or Dialog and Alert dialog?

Open
Modal (shadcn: Dialog)
Modal confirmation (shadcn: Alert dialog)
Built

Modal and Modal confirmation, your words. Two names that say they are one family.

shadcn

Dialog and Alert dialog. The dashboard's older files carry those names today, and so does Base UI under both.

A section that starts with a box and not a line of text: 12px above it, or 16?

Open
Built

12px, whatever the section starts with. An alert or a bare control then sits 4px closer to the line above than to the sides. A picture alone is not a section today: its screen pads it 16px on all four sides.

The other way

A way to say what a section starts with, as ends says what it ends with.

Is running text cut part-way too?

Open
Built

No. A paragraph has no rows, so the body ends where the room ends and the cover alone says there is more.

Your words

“The paragraph might be super long, so I don't know about this two-thirds thing.”

Catalog
Foundations
  • Overview
  • Tokens
  • Token usage
  • Typography
  • Icons
Atoms
  • Avatar
  • Badge
  • Button
  • Checkbox
  • Color picker
  • Copy button
  • Icon tooltip
  • Inline code
  • Input
  • Hint
  • Kbd
  • Loader
  • Native select
  • Progress bar
  • Progress ring
  • Radio
  • Select
  • Status dot
  • Switch
  • Text link
  • Textarea
  • Tooltip
  • Truncate
Molecules
  • Accordion
  • Activity chart
  • AI elements
  • Alert
  • Button group
  • Card
  • Code block
  • Combobox trigger
  • Command
  • Context switcher
  • Dropdown menu
  • Empty state
  • Field
  • Field group
  • Filter chip
  • Flow
  • Icon picker
  • Metric card
  • Modal
  • Modal confirmation
  • Pagination
  • Popover
  • Scroll area
  • Sidebar
  • Table
  • Tabs
  • Toggle group
LibraryPublished release