Dialog
Displays content in a popup with focus management and dismissal controls.
Dialog Default
The preview uses AlertModal for a confirmation action with a loading indicator.
import { useState } from "react";
import { AlertModal } from "@notion-kit/ui/alert-modal";
import { Button, Dialog, DialogTrigger } from "@notion-kit/ui/primitives";
export default function ConfirmationDialog() {
const [open, setOpen] = useState(false);
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger render={<Button size="md">Open</Button>} />
<AlertModal
title="This action cannot be undone. This will permanently delete your account and remove your data from our servers."
primary="Continue"
secondary="Cancel"
onTrigger={async () => {
await new Promise((resolve) => setTimeout(resolve, 1500));
setOpen(false);
}}
/>
</Dialog>
);
}Installation
pnpm add @notion-kit/uiAnatomy
Dialog owns the open state. DialogTrigger opens the popup, and DialogClose closes it.
DialogContent includes the portal, overlay, and a close button.
An extra DialogPortal or DialogOverlay is unnecessary when using DialogContent.
DialogTitle supplies the accessible name. DialogDescription supplies the description when the popup has explanatory text.
Examples
Custom content
This dialog manages its own open state. The footer supplies a custom close action in place of the default close button.
import {
Button,
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@notion-kit/ui/primitives";
<Dialog>
<DialogTrigger render={<Button size="md">View details</Button>} />
<DialogContent hideClose>
<DialogHeader>
<DialogTitle>Workspace details</DialogTitle>
<DialogDescription>
Manage the settings for this workspace.
</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button size="md">Done</Button>} />
</DialogFooter>
</DialogContent>
</Dialog>;API reference
Dialog
Wraps Base UI's Dialog.Root and does not render a DOM element.
Common root props are listed below. Other props follow Base UI's root reference.
Prop
Type
DialogContent
Accepts Base UI's Dialog.Popup props and these additions.
Prop
Type
DialogTitle and DialogDescription
Accept the corresponding Base UI title and description props, plus typography.
Prop
Type
Other parts
These parts retain their underlying props:
DialogTriggeraccepts Base UI'sDialog.Triggerprops. Itsrenderprop composes withButton.DialogCloseaccepts Base UI'sDialog.Closeprops. It rendersCloseButtonunlessrendersupplies a replacement.DialogPortalandDialogOverlayaccept Base UI's portal and backdrop props.DialogHeader,DialogFooter, andDialogIconaccept HTML<div>props and provide layout styles.
AlertModal
Imported from @notion-kit/ui/alert-modal. Renders confirmation content inside a parent Dialog, including a title and two action buttons.
The primary action displays a spinner while onTrigger is pending. The secondary action closes the dialog.
Resolving onTrigger does not close the dialog automatically.
Prop
Type