Modal
A dialog that interrupts the current context to focus the user on a task.
- Status
- ReadyBuild day 15 of 21
- Code
- In React
- Role
- Overlay
Usage
This demo is live, and the code below it is the same code, imports included. The component lives in src/ui of this repository and is not published to npm yet.
Pastes as editable layers. Shadows are not exported.
import { useState } from "react";
import { Button, Modal } from "@/ui";
export default function ModalDemo() {
const [open, setOpen] = useState<boolean>(false);
return (
<>
<Button variant="destructive" onClick={() => setOpen(true)}>Remove saved account</Button>
<Modal
open={open}
onClose={() => setOpen(false)}
title="Remove saved account?"
description="“Andi Pratama” will be removed from your saved accounts."
footer={<Button variant="destructive" onClick={() => setOpen(false)}>Remove</Button>}
/>
</>
);
}Variants and states
Every specimen is the real component from src/ui, held in one state.
These are the dialog box on its own. Modal adds the backdrop, the focus trap, and Escape.
Remove saved account?
Remove saved account?
Remove saved account?
Remove saved account?
Remove saved account?
Remove saved account?
Pastes as editable layers. Shadows are not exported.
Props
- open, onClose
- boolean, () => void · default none
- Required on Modal. onClose runs for the close button, the backdrop, and Escape.
- title
- string · default none
- Required. Names the dialog.
- description
- ReactNode · default none
- type
- "confirmation" | "form" | "alert" · default "confirmation"
- Alert adds a warning icon.
- size
- "sm" | "md" | "lg" | "xl" · default "sm"
- 400, 560, 720, 960 wide.
- children
- ReactNode · default none
- The body, such as form fields.
- footer
- ReactNode · default none
- Buttons, right aligned.
- ModalPanel
- component · default none
- The box on its own, for documentation.
Figma to code
Figma properties by their exact names from Naming, and the React prop that carries each one. The table covers the shared properties that bear on this component; the Figma file decides which of them its component exposes. None means there is no prop for it yet.
- 🧰 Type
- type
- confirmation, form, or alert.
- 📐 Size
- size
- sm to xl.
- Show Close
- onClose
- On ModalPanel, pass onClose.
- Title, Show Description, Description
- title, description
- Same.
- Show Button
- footer
- Pass your buttons.
Accessibility
What the code in src/ui does today, and what it leaves to you.
Keyboard
- A native dialog: focus moves in, Tab stays inside, Escape closes, and focus returns to the trigger.
Screen readers
- Named by its title. The page behind is inert.
What you still need to do
- One primary action. A destructive one uses the destructive Button and a clear verb, such as Remove.
- For something that is not critical, use a Drawer or the page itself.
When to use
Focused tasks, confirmations, and critical information that needs immediate attention.
Do and don't
Do
- Provide a clear way to dismiss (close button, escape key, backdrop click).
- Keep content focused on a single task.
Don't
- Stack multiple modals on top of each other.
- Use for content that could be a regular page or panel.
Related
4 of 28 other molecules, same role and ready ones first.
- DrawerA panel that slides in from the edge of the screen over the page.Ready
- TooltipA small popup that shows brief, supplementary information on hover or focus.Ready
- AccordionStacked sections that expand to reveal their content.Ready
- AlertA persistent, inline message that communicates important information.Ready
Status reflects the component tracker snapshot of 29 October 2026.