1. Documentation
  2. Overlays
  3. Dialog
ReadmenpmGitHub
  • Introduction
  • Installation
  • Theming
  • Icons
  • Accordion
  • Card
  • Scroll Area
  • Separator
  • Sidebar
  • Field
  • Label
  • Input
  • Textarea
  • Number Field
  • OTP Field
  • Select
  • Combobox
  • Checkbox
  • Radio
  • Switch
  • Slider
  • Toggle
  • Calendar
  • Date Picker
  • File Upload
  • Button
  • Copy Button
  • Dropdown
  • Command
  • Tabs
  • Breadcrumb
  • Pagination
  • Tree
  • Table
  • Data Table
  • Stat
  • Timeline
  • Avatar
  • Status Bar
  • Badge
  • Meter
  • Empty
  • Skeleton
  • Spinner
  • Toast
  • Dialog
  • Sheet
  • Popover
  • Tooltip
  • Text
  • Kbd
  • Code Block
  • Utilities
  • Design rules

Dialog

One modal task — and one component, because an alert and a confirmation are a prop and two buttons.

Loading documentation…

Toast< PreviousSheetNext >

Powered by heyo

On this page

UsageA confirmationUndismissibleSizesPropertiesDialogDialog.ContentThe parts
<Dialog><Dialog.Trigger render={<Button>Invite a teammate</Button>} /><Dialog.Content>  <Dialog.Header>    <Dialog.Title>Invite a teammate</Dialog.Title>    <Dialog.Description>They will get access to every project.</Dialog.Description>  </Dialog.Header>  <Dialog.Body>    <Input label="Email" placeholder="you@example.com" />  </Dialog.Body>  <Dialog.Footer>    <Dialog.Close render={<Button variant="ghost">Cancel</Button>} />    <Button variant="primary">Send invite</Button>  </Dialog.Footer></Dialog.Content></Dialog>

A dialog is a modal task: it locks the page because it demands an answer. That is also the only thing in heyo-ui that does, besides Sheet.

There is one Dialog, not three. dismissible={false} covers what used to be AlertDialog, and a confirmation is a dialog with two buttons in its footer — there is nothing left for a ConfirmDialog to add.

Usage

tsx
import { Button, Dialog } from "@heyo-sh/heyo-ui";<Dialog>  <Dialog.Trigger render={<Button>Invite</Button>} />  <Dialog.Content>    <Dialog.Header>      <Dialog.Title>Invite a teammate</Dialog.Title>    </Dialog.Header>    <Dialog.Body>…</Dialog.Body>  </Dialog.Content></Dialog>;

A confirmation

Two buttons in the footer, the destructive one on the right. Nothing else is needed, and nothing else should be there.

<Dialog><Dialog.Trigger render={<Button variant="destructive-secondary">Delete</Button>} /><Dialog.Content size="sm">  <Dialog.Header>    <Dialog.Title>Delete acme-api?</Dialog.Title>    <Dialog.Description>This cannot be undone.</Dialog.Description>  </Dialog.Header>  <Dialog.Footer>    <Dialog.Close render={<Button variant="ghost">Cancel</Button>} />    <Button variant="destructive">Delete forever</Button>  </Dialog.Footer></Dialog.Content></Dialog>

Undismissible

dismissible={false} is the old "alert dialog": the backdrop and Escape stop closing it, so the reader has to answer. Use it only when dismissing would lose work or leave something half-done — everything else should be dismissible.

<Dialog dismissible={false}><Dialog.Trigger render={<Button>Finish setup</Button>} /><Dialog.Content size="sm" hideClose>  <Dialog.Header>    <Dialog.Title>Pick a region</Dialog.Title>    <Dialog.Description>Your worker cannot deploy without one.</Dialog.Description>  </Dialog.Header>  <Dialog.Footer>    <Dialog.Close render={<Button variant="primary">Use Frankfurt</Button>} />  </Dialog.Footer></Dialog.Content></Dialog>

Sizes

sm, base, lg and xl. The body scrolls on its own, so the header and footer stay put however long the content gets — and the corner close button sits above a scrolled body rather than under it.

A side quest, not a task?

Use a Sheet when the content is a detail pane or a filter panel — something you look at beside the page rather than instead of it.

Properties

Dialog

dismissiblebooleanoptional

Whether clicking the backdrop or pressing Escape closes the dialog. It defaults to true.

open / defaultOpenbooleanoptional

Controlled and uncontrolled state.

onOpenChange(open: boolean) => voidoptional

Fires on open and close.

Dialog.Content

size"sm" | "base" | "lg" | "xl"optional

Maximum width. It defaults to base.

hideClosebooleanoptional

Hides the built-in corner close button. Only sensible when the footer has one.

The parts

Dialog.Triggerrenderoptional

Anything that opens the dialog.

Dialog.Header / Title / Description—optional

The heading block. Title and Description are wired to the dialog's accessible name and description.

Dialog.Body—optional

The scrolling content column.

Dialog.Footer—optional

Right-aligned actions.

Dialog.Closerenderoptional

Closes the dialog. Pass render={<Button />} for a footer button.

Dialog.CloseButton—optional

The corner dismiss, rendered for you unless hideClose is set.