Alert Dialog

A modal dialog that interrupts the user with important content and expects a response.

Overview

The Alert Dialog component is a modal that interrupts the user to display critical information or request confirmation. Built on Base UI primitives, it supports URL state management for deep linking and shareable dialog states.

Usage

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogClose,
  AlertDialogContent,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogTrigger,
} from "@tilt-legal/cubitt-components/primitives";
<AlertDialog>
  <AlertDialogTrigger>Open</AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogIcon>
        <MobiusLogo variant="mark" color="gradient" className="w-14! h-14!" />
      </AlertDialogIcon>
      <AlertDialogTitle>Are you sure?</AlertDialogTitle>
      <AlertDialogDescription>
        This action cannot be undone.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogClose>Cancel</AlertDialogClose>
      <AlertDialogAction>Continue</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Examples

Destructive Action

URL State

API Reference

AlertDialog

PropTypeDescription
openbooleanThe controlled open state of the dialog.
defaultOpenbooleanThe default open state when uncontrolled. Defaults to false.
onOpenChange(open: boolean, eventDetails) => voidCallback fired when the open state changes.
animatedbooleanWhether to enable open/close animations. Defaults to true.
closeOnBackdropClickbooleanWhether clicking the backdrop closes the dialog. Defaults to false.
closeOnEscapebooleanWhether pressing Escape closes the dialog. Defaults to true.
classNamestringAdditional CSS classes for the dialog root.

URL State Props

When provided with a paramName, the alert dialog's state will be reflected in the URL.

PropTypeDescription
paramNamestringURL parameter name for syncing state with URL. When provided, enables URL state management.
paramMatchValuestringValue that must match for the alert dialog to open.
onUrlValueChange(value: boolean | null) => voidCallback when URL parameter value changes.
paramClearOnDefaultbooleanRemove URL param when value equals default. Defaults to true.
paramThrottlenumberThrottle URL updates in milliseconds.
paramDebouncenumberDebounce URL updates in milliseconds.

AlertDialogTrigger

PropTypeDescription
renderReactElement | functionCustom element to render as the trigger.
classNamestringAdditional CSS classes for the trigger.

AlertDialogContent

PropTypeDescription
showDismissButtonbooleanWhether to show a dismiss (X) button. Defaults to false.
showBackdropbooleanWhether to show the backdrop overlay. Defaults to true.
classNamestringAdditional CSS classes for the content.

AlertDialogHeader

PropTypeDescription
classNamestringAdditional CSS classes for the header.

AlertDialogFooter

PropTypeDescription
classNamestringAdditional CSS classes for the footer.

AlertDialogTitle

PropTypeDescription
classNamestringAdditional CSS classes for the title.

AlertDialogDescription

PropTypeDescription
classNamestringAdditional CSS classes for the description.

AlertDialogAction

PropTypeDescription
renderReactElement | functionCustom element to render (e.g., styled button).
classNamestringAdditional CSS classes for the action.

AlertDialogClose

PropTypeDescription
renderReactElement | functionCustom element to render (e.g., styled button).
classNamestringAdditional CSS classes for the close button.

On this page