Back to Tooljet

AlertDialog — Rocket Design Spec

frontend/src/components/ui/Rocket/AlertDialog/AlertDialog.spec.md

3.20.154-lts4.8 KB
Original Source

AlertDialog — Rocket Design Spec

<!-- figma: https://www.figma.com/design/XQdM9x8x9YHcj1lUK8abUG/Rocket-components?node-id=8996-1761 --> <!-- synced: 2026-04-01 -->

Overview

AlertDialog is a modal confirmation dialog that cannot be dismissed by pressing Escape or clicking outside. The user must explicitly choose an action (confirm or cancel). Used for destructive or irreversible operations.

Structurally simpler than Dialog — no header/footer borders, no body scroll. Uses Radix AlertDialog primitives which enforce the non-dismissible behavior natively.

Props (AlertDialogContent)

PropTypeValuesDefault
sizestringdefault | smalldefault
classNamestring

Sizes

ValueMax-widthHeader alignmentFooter layout
default460pxleft-alignedhorizontal, justify-between
small360pxcenteredstacked, reverse order

Sub-components

ComponentWrapsStyling
AlertDialogRadix AlertDialog.Root (pass-through)none
AlertDialogTriggerRe-export from shadcnnone
AlertDialogPortalRe-export from shadcnnone
AlertDialogOverlayRadix Overlay (direct)tw-bg-black/50, animations
AlertDialogContentRadix Content (direct)card with padding, shadow, rounded, size CVA
AlertDialogMediaplain div40px icon/image slot
AlertDialogHeaderplain divgroups media + title + description
AlertDialogTitleRadix Title (direct)tw-font-title-x-large + color
AlertDialogDescriptionRadix Description (direct)tw-font-body-default + color
AlertDialogFooterplain divjustify-between layout, no border
AlertDialogActionRadix Action (direct)accepts Rocket Button as child via asChild
AlertDialogCancelRadix Cancel (direct)accepts Rocket Button as child via asChild

Token Mapping

ElementStateFigma tokenToolJet class
content bgdefaultbg-surface-layer-01tw-bg-background-surface-layer-01
content shadowdefaultElevations/400tw-shadow-elevation-400
content radiusdefault8pxtw-rounded-lg
content paddingdefault24pxtw-p-6
content gapdefault24px (between body and footer)tw-gap-6
overlay bgdefaultblack/50tw-bg-black/50
media sizedefault40pxtw-size-10
body gapdefault8px (between media/title/desc)tw-gap-2
title textdefaulttext/default, 16px Medium 24pxtw-font-title-x-large tw-text-text-default
description textdefaulttext/default, 12px Regular 18pxtw-font-body-default tw-text-text-default
footer layoutdefaultjustify-betweentw-flex tw-justify-between tw-items-center

Slots

  • media (optional, ReactNode) — 40px icon or image at top, via AlertDialogMedia
  • title (required, string) — heading text
  • description (optional, string) — supporting text
  • cancel (required) — Rocket Button (typically variant="outline")
  • action (required) — Rocket Button (typically variant="primary" or variant="primary" danger)
  • secondary action (optional) — additional Rocket Button grouped with action on the right

Usage Pattern

jsx
<AlertDialog>
  <AlertDialogTrigger asChild>
    <Button variant="primary" danger>Delete</Button>
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogMedia><WarningIcon /></AlertDialogMedia>
      <AlertDialogTitle>Are you sure?</AlertDialogTitle>
      <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel asChild>
        <Button variant="outline">Cancel</Button>
      </AlertDialogCancel>
      <AlertDialogAction asChild>
        <Button variant="primary" danger>Delete</Button>
      </AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

CVA Shape

Shape C — sizes only. alertDialogContentVariants has size CVA for max-width. Rest use static cn() with group-data-[size=...] responsive classes.

Notes

  • Non-dismissible by design: Radix AlertDialog natively prevents Escape and overlay click dismiss. No preventClose prop needed (unlike Dialog).
  • No header/footer borders — simpler layout than Dialog.
  • No close button (X) — users must use Cancel or Action.
  • small size: header text centers, footer stacks buttons vertically (reversed so action is on top).
  • Footer uses Rocket Button components directly via asChild on Action/Cancel.
  • The right side of the footer (default size) can hold multiple action buttons (secondary + primary) grouped with tw-gap-2.
  • Typography uses tw-font-* plugin utilities — never manual font combos.
  • data-size attribute on Content enables group-data-[size=small] selectors on child components.