App components / Modals
Modal
A tray holding a raised card. The title sits on the tray with an esc key, the content in the card, and the actions below with a ⌘ ↵ hint. Confirms open with a mono context line instead of an icon. On phones it rises from the bottom as a sheet.
Code
The component itself, ready to drop into your project. Switch between React, Vue and plain HTML; every version uses the same Tailwind classes on Ochre's tokens.
Installation
Examples
With a form
Fields in the card, ⌘ ↵ submits.
Confirm destructive
Removing or deleting: the Danger button comes last and the hint names the action.
Sizes
S 400 to XXL 880 wide. Every size is the same bottom sheet on phones.
Desktop and Mobile
Drawn in place: a description and a header action on desktop, the stacked footer of the phone sheet beside it.
Invite people
They get an email with a link to join.
Separate addresses with commas.
Invite people
Northwind · 38 of 50 seats
Separate addresses with commas.
Motion
Built on Ochre's ease-out curves. With reduced motion switched on, everything still works, it just doesn't move.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | – | Whether the dialog is showing. |
| onClose | () => void | – | Called on esc, the esc key, or a click outside. |
| title | ReactNode | – | Short, sentence case, says what happens: Archive project. |
| context | ReactNode | – | Mono line at the top of the card: the object and what it affects. |
| actions | ReactNode | – | Buttons on the tray, quiet first and the confirming one last. |
| onConfirm | () => void | – | Runs on ⌘↵ / Ctrl+Enter and shows the hint. |
| data-autofocus | attribute on a field | – | Opening focuses the tray, so no control looks pre-selected. Put data-autofocus on a field to start there instead. |
| hint | ReactNode | – | Replaces the default keyboard hint on the left of the footer. |
| size | "s" | "m" | "l" | "xl" | "xxl" | "m" | 400, 480, 560, 680 or 880 pixels wide on larger screens. |
| description | ReactNode | – | A line under the title on the tray (the Dialog header's Title type). |
| headerActions | ReactNode | – | Small 24 px key-style controls before the esc key, such as copy link. |
| showEsc | boolean | true | Hide the esc key only when something else on the strip closes the dialog. |
| footer | "inline" | "stacked" | "auto" | "inline" | Inline puts the buttons in a row; Stacked gives each a full-width row with the confirming one on top; Auto stacks them on phones only. |
| inline | boolean | false | Draws the tray in place instead of opening a dialog: previews, docs, design reviews. |
| layout | "auto" | "desktop" | "mobile" | "auto" | Auto follows the screen (bottom sheet below 640 px). Desktop or Mobile fixes the look for a tray drawn in place. |
| ModalPanel | component | – | The tray on its own (title strip, card, actions), for building other overlays on the same anatomy. |
Usage
Use it for
- A decision that needs the person's full attention: confirm, create, connect.
- Short forms of up to about five fields.
- Ready-made content for common situations: see Modal templates.
Avoid
- Long forms or anything people need to compare with the page: use a Slide-out panel.
- Modals that open other modals.
- A corner X: Ochre closes with the esc key on the title strip.