Pull
Remove a sheet from the run. The question sits on paper.
Focuses attention on a modal task. Title, body, and two equal actions.
Remove a sheet from the run. The question sits on paper.
Three ways in. They share one source, so the pixels match whichever you pick.
npm install @noorddev/vlak-react
// once, next to your app's root
import "@noorddev/vlak-react/css";
import { Button, Dialog, DialogActions, DialogBody, DialogTitle } from "@noorddev/vlak-react";Precompiled React and one stylesheet. No compiler to configure. Per-component imports work too: @noorddev/vlak-react/components/dialog.
npx @noorddev/vlak-cli add dialog
The StyleX leaf lands in components/vlak/ with its dependencies, for your own compiler to own. See StyleX.
npx shadcn add https://vlak.dev/r/dialog.json
The same registry item, installed by shadcn's CLI.
<link rel="stylesheet" href="node_modules/@noorddev/vlak/css/vlak.css" />
No React. Link vlak.css and use the markup and classes below.
import { useState } from "react";
import { Button, Dialog, DialogActions, DialogBody, DialogTitle } from "@noorddev/vlak-react";
const [open, setOpen] = useState(false);
<Button variant="ghost" onClick={() => setOpen(true)}>Remove</Button>
<Dialog open={open} onClose={() => setOpen(false)} closeLabel="Close">
<DialogTitle>Remove this item?</DialogTitle>
<DialogBody>This can't be undone.</DialogBody>
<DialogActions>
<Button variant="ghost" size="sm" onClick={() => setOpen(false)}>Cancel</Button>
<Button size="sm" onClick={remove}>Remove</Button>
</DialogActions>
</Dialog>A native <dialog>. Focus trapping, Escape, and the backdrop come from the platform; the title names it and the body describes it.
| Prop | Type | Default | Description |
|---|---|---|---|
openrequired | boolean | ||
onClose | () => void | ||
dismissable | boolean | Escape (and any other platform close request) asks the parent to close. Off, the dialog must be answered; maps to closedby="none". | |
lightDismiss | boolean | A click on the backdrop closes too; maps to closedby="any". | |
closeLabel | string | Renders a labelled close button in the top corner. | |
extraStyles | Leaves | Extra StyleX leaves merged after the dialog frame (command palette). |
Also accepts Omit<DialogHTMLAttributes<HTMLDialogElement>, "open" | "onClose">.
Also accepts HTMLAttributes<HTMLDivElement>.
Also accepts HTMLAttributes<HTMLParagraphElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
as | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div" | "h2" | Heading level. The dialog is named by this element either way. |
Also accepts HTMLAttributes<HTMLHeadingElement>.
| Keys | Does |
|---|---|
| Escape | Calls onClose (when dismissable, the default) |
| Tab, Shift + Tab | Cycles focus inside the open dialog |
| Enter, Space | Activates the focused action |
<div class="rs-dialog" role="dialog" aria-labelledby="remove-title" aria-describedby="remove-body"><h2 class="rs-dialog-title" id="remove-title">Remove this item?</h2><p class="rs-dialog-body" id="remove-body">This can't be undone.</p><div class="rs-dialog-actions"><button class="rs-btn-ghost rs-btn-sm">Cancel</button><button class="rs-btn-primary rs-btn-sm">Remove</button></div></div>