Dialog
A modal dialog: 440, 560 or 720 wide, radius 20; title, description, body, actions. ⌘Enter submits. 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
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.
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 calls this (usually the primary action).
openbooleanWhether it is open, when you control it.
size"md" | "sm" | "lg"The dialog's width.
titleReactNodeThe dialog's heading, also its accessible name.
triggerReactElement<unknown, string | JSXElementConstructor<any>>The trigger, a single element.