Dialog
A window overlaid on either the primary window or another dialog window, rendering the content underneath inert.
import { Dialog } from "@ngrok/mantle/dialog";
<Dialog.Root>
<Dialog.Trigger asChild>
<Button type="button">Open dialog</Button>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>Are you absolutely sure?</Dialog.Title>
</Dialog.Header>
<Dialog.Body>
This action cannot be undone. This will permanently delete your account and remove your data from our
servers.
</Dialog.Body>
<Dialog.Footer>
<Button type="button">
Delete
</Button>
<Button type="button">
Cancel
</Button>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Root>
Composition
In some cases, you might wish to have a tooltip over the dialog trigger. This is helpful if the dialog trigger is an IconButton
and you wish to provide more context to what the button does. You can compose them both together to where the dialog trigger is also the tooltip trigger.
<Dialog.Root>
<Tooltip.Root>
<Tooltip.Trigger asChild>
<Dialog.Trigger asChild>
<IconButton type="button" label="Delete" size="sm" icon={<TrashSimpleIcon />} />
</Dialog.Trigger>
</Tooltip.Trigger>
<Tooltip.Content>
<p>Delete</p>
</Tooltip.Content>
</Tooltip.Root>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>Are you absolutely sure?</Dialog.Title>
<Dialog.CloseIconButton />
</Dialog.Header>
<Dialog.Body>
This action cannot be undone. This will permanently delete your account and remove your data from our
servers.
</Dialog.Body>
<Dialog.Footer>
<Dialog.Close asChild>
<Button type="button" priority="danger" appearance="filled">
Delete
</Button>
</Dialog.Close>
<Dialog.Close asChild>
<Button type="button" priority="neutral" appearance="outlined">
Cancel
</Button>
</Dialog.Close>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Root>
API Reference
The Dialog
component is built on top of Radix UI Dialog and provides a complete set of sub-components for building modal dialogs.
Dialog.Root
The root stateful component that manages the open/closed state of the dialog.
Dialog.Trigger
A button that opens the dialog.
Dialog.Content
The container for the dialog content. Renders on top of the overlay and is centered in the viewport.
Dialog.Header
Contains the header content of the dialog, including the title and close button.
Dialog.Body
Contains the main content of the dialog.
Dialog.Footer
Contains the footer content of the dialog, including action buttons.
Dialog.Title
An accessible name to be announced when the dialog is opened.
Dialog.Description
An accessible description to be announced when the dialog is opened.
Dialog.Close
A button that closes the dialog when clicked.
Dialog.CloseIconButton
An icon button that closes the dialog when clicked.