Dialog

A modal window that overlays the main content, requiring user interaction before returning to the application.

Overview

The Dialog component is a modal window that displays content on top of the main application, requiring user interaction before continuing. Built on Base UI primitives, it features smooth animations, backdrop blur effects, sticky headers and footers for scrollable content, and flexible sizing options including fullscreen mode.

Usage

import {
  Dialog,
  DialogTrigger,
  DialogContent,
  DialogHeader,
  DialogTitle,
  DialogDescription,
  DialogBody,
  DialogFooter,
  DialogClose,
  DialogAction,
} from "@tilt-legal/cubitt-components/primitives";
<Dialog>
  <DialogTrigger render={<Button />}>Open Dialog</DialogTrigger>
  <DialogContent>
    <DialogHeader>
      <DialogTitle>Dialog Title</DialogTitle>
      <DialogDescription>Dialog description goes here.</DialogDescription>
    </DialogHeader>
  </DialogContent>
</Dialog>

Examples

Dialog with Form

Dialog containing form inputs for data entry.

Scrollable Content

Dialog with long content that scrolls. The header and footer remain sticky with a blurred background effect.

The scrollbar track is automatically inset to clear the sticky header and footer areas. This is controlled via CSS custom properties --scrollbar-inset-top and --scrollbar-inset-bottom, which default to 3.5rem inside DialogContent. You can override these per-dialog if your header or footer has a non-standard height:

<DialogContent className="[--scrollbar-inset-top:5rem] [--scrollbar-inset-bottom:4rem]">
  {/* ... */}
</DialogContent>

Fullscreen Dialog

Dialog that takes up most of the screen, useful for complex forms or detailed content.

Without Dismiss Button

Dialog without the X close button in the top right corner.

Nested Dialogs

Open a dialog from within another dialog. The parent dialog will scale down and shift to create a visual hierarchy.

URL State

Dialog with URL state synchronization for shareable dialog states.


API Reference

Dialog

Root component that manages dialog state.

PropTypeDefaultDescription
openboolean-Controlled open state of the dialog.
defaultOpenbooleanfalseDefault open state for uncontrolled usage.
onOpenChange(open: boolean) => void-Callback fired when the open state changes.
modalbooleantrueWhether the dialog is modal (locks scroll).
disabledbooleanfalseWhether the dialog is disabled.

URL State Props

When provided with a paramName, the dialog will sync its open/closed state with URL parameters via TanStack Router search params.

PropTypeDefaultDescription
paramNamestringURL parameter name for syncing state with URL. Enables URL state management.
paramMatchValuestringValue that must match for the dialog to open.
onUrlValueChange(value: string) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleantrueRemove URL param when dialog is closed.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

DialogTrigger

Button that opens the dialog.

PropTypeDefaultDescription
renderReact.ReactElement-Custom trigger element to render.
disabledbooleanfalseWhether the trigger is disabled.

DialogContent

Container for the dialog content with backdrop and animations.

PropTypeDefaultDescription
showBackdropbooleantrueWhether to show the backdrop overlay.
showDismissButtonbooleantrueWhether to show the X close button in the top right.
fullscreenbooleanfalseWhether the dialog should take up most of the screen.
nestedOffsetbooleantrueWhether to apply offset transforms for nested dialogs based on nesting depth.
classNamestring-Additional CSS classes for the dialog popup.

CSS Custom Properties

VariableDefaultDescription
--scrollbar-inset-top3.75remTop margin of the scrollbar track (clears sticky header)
--scrollbar-inset-bottom4remBottom margin of the scrollbar track (clears sticky footer)

DialogHeader

Container for dialog title and description with sticky positioning.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the header.

DialogTitle

The accessible title of the dialog.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the title.

DialogDescription

Description text that provides context about the dialog.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the description.

DialogBody

Container for the main dialog content.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the body.

DialogFooter

Container for dialog actions with sticky positioning.

PropTypeDefaultDescription
classNamestring-Additional CSS classes for the footer.

DialogClose

Button that closes the dialog (styled as outline button by default).

PropTypeDefaultDescription
renderReact.ReactElement-Custom close button element to render.
classNamestring-Additional CSS classes for the close button.

DialogAction

Primary action button that closes the dialog (styled as default button).

PropTypeDefaultDescription
renderReact.ReactElement-Custom action button element to render.
classNamestring-Additional CSS classes for the action button.

On this page