Dialog
A modal dialog: 440, 560 or 720 wide, radius 14; title, description, body, actions. Enter in a field and ⌘Enter submit. Longer forms use StepDialog: one question per step.
function Form() {
const [open, setOpen] = useState(false);
const create = () => {
setOpen(false);
toast.success("Key created");
};
return (
<>
<Dialog
open={open}
onOpenChange={setOpen}
trigger={<Button variant="primary">Create key</Button>}
title="Create key"
description="Applications use this key to call the gateway."
onSubmit={create}
footer={
<>
<Dialog.Close>
<Button>Cancel</Button>
</Dialog.Close>
<Button variant="primary" onClick={create} shortcut={["mod", "enter"]}>
Create key
</Button>
</>
}
>
<div className="flex flex-col gap-20">
<Input label="Name" placeholder="checkout-web" autoFocus />
<Select
label="Expires"
options={[
{ value: "never", label: "Never" },
{ value: "90", label: "In 90 days" },
]}
defaultValue="90"
fullWidth
/>
</div>
</Dialog>
</>
);
}import { Dialog } from "@logicplanes/kaeso-ui";Props
anchor"top" | "center" = topWhere it sits: centered, or with a fixed top edge for content that changes height, so the title never moves.
busybooleanKeeps the dialog open while work it started is underway: Escape, a press outside, the close circle, Dialog.Close, Enter and ⌘Enter do nothing, so a request is never abandoned or sent twice.
childrenReactNodeThe dialog's content and actions.
defaultOpenbooleanWhether it starts open, when the component keeps its own state.
descriptionReactNodeOne sentence under the title.
footerReactNodeRight-aligned actions: Cancel (secondary) then the primary.
footerStartReactNodeA quiet action at the footer's start, such as a link to another way of doing the task.
headerStartReactNodeA top bar above the title, with this at its start and the close circle at its end (LayerDialog's back button). The title, description and content keep one left edge;
nullkeeps the bar with an empty start.hideClosebooleanHide the close circle (rare).
inlinebooleanRender without a portal and backdrop, for documentation and state matrices.
onOpenChange((open: boolean) => void)Called when it opens or closes.
onSubmit(() => void)Enter in a single-line field and ⌘/Ctrl+Enter anywhere call this (usually the primary action); Enter in a text area, a search field, a combobox or a picker, and the Enter that confirms an input method's text, keep their own meaning.
openbooleanWhether it is open, when you control it.
persistentbooleanA press outside doesn't close it or move the focus, for forms that would lose what was typed; Escape and the close circle still close it. Every StepDialog is persistent.
size"md" | "sm" | "lg"The dialog's width.
titleReactNodeThe dialog's heading, also its accessible name; a long one, or an id, wraps.
toolbarReactNodeControls that stay under the title while the body scrolls, such as a search over the list below; a hairline shows once the body is scrolled.
triggerReactElement<unknown, string | JSXElementConstructor<any>>The trigger, a single element.