Skip to content

Dialog

The Dialog component provides an accessible and customizable dialog overlay for displaying important content or requesting user input. It supports different sizes, themes, and can include an icon or logo in the header.

Playground

Custom trigger focus

If a dialog is opened without the Trigger component (e.g., a dropdown item), focus will not return to the trigger element when the dialog is closed. To address this use useCustomDialogTrigger hook to register your custom trigger element.

Installation

import { Dialog } from "@harnessio/ui/components";
// ...
return (
<Dialog.Root>
<Dialog.Trigger>
<Button>Open Dialog</Button>
</Dialog.Trigger>
<Dialog.Content size="md">
<Dialog.Header icon="plus-circle">
<Dialog.Title>Dialog Title</Dialog.Title>
<Dialog.Description>Optional description text</Dialog.Description>
</Dialog.Header>
<Dialog.Body>
Dialog content goes here
</Dialog.Body>
<Dialog.Footer>
<Dialog.Close>Cancel</Dialog.Close>
<Button variant="primary">Confirm</Button>
</Dialog.Footer>
</Dialog.Content>
</Dialog.Root>
)