Raft Design System

Components · Overlays

AlertDialog

A small centered confirmation with the alertdialog role, for the few confirmations a product lists; every other confirmation is a Dialog at size sm.

StableAlso called ConfirmDialog, Confirmation
import { AlertDialog } from "@botiverse/raft-ui";

An alert dialog asks people to confirm an action before it happens, with the alertdialog role, so a screen reader announces it as an interruption. Most confirmations aren't built on it: a confirmation is a Dialog at size="sm", deleting and stopping included, and a product lists the few that use AlertDialog instead (Choosing a component, 2026-11-03). In Raft Chat there are two: discarding unsaved edits to an agent's profile, and opening a link that hands off to another app (Raft Chat). It is a 400px dialog on a scrim, the width of every confirmation, with a title, a sentence on what will happen, Cancel and a confirm button whose color states the consequence.

alert-dialog/compositions/confirm-action

When to use

SituationUse
A confirmation the product lists as an AlertDialog: in Raft Chat, discarding unsaved edits to an agent's profile, opening a link that hands off to another appAlertDialog, its confirm button colored by the consequence (Variants)
Any other confirmation, including an action that cannot be undone (delete a message, an agent, a server) or that interrupts but can be recovered (stop an agent, reset a session, leave a channel)A Dialog at size="sm", its confirm button red or orange by the same table (Variants)
An action that can be reversed in placeNo dialog: do it; when a Toast offers Undo is in Feedback
A decision that needs more than the name typedDialog

Anatomy

  • AlertDialog: the root. Required.
  • AlertDialogTrigger: the button that opens it. Usually the dialog is opened from a menu item instead.
  • AlertDialogContent: the centered surface, at most 400px wide, the width of a size="sm" Dialog, so every confirmation is one width, with the scrim (AlertDialogOverlay) behind it. Required.
  • AlertDialogHeader: the title row, with an optional AlertDialogClose (×).
  • AlertDialogTitle: the title. Required.
  • AlertDialogBody: the content under the header, in the base ink (foreground).
  • AlertDialogDescription: what will happen, in foreground-muted. It takes only a HelperText, made with helperText(content, { why, about }), and renders its why and about as data-why and data-about; a confirmation's line is usually consequence (Writing › Helper text).
  • AlertDialogFooter: the buttons in one row at the end, Cancel then the commit button, on a phone as on a desktop. Only when they don't fit on one line do they stack full width, the commit button on top and Cancel framed, as in Dialog.
  • AlertDialogCancel: a ghost button that closes the dialog; framed when the buttons stack. Required.
  • AlertDialogAction: the confirm button. It is a Button and doesn't close the dialog by itself: close it when the action finishes.
  • AlertDialogPortal: a lower-level part.

Variants

The confirm button's color says what happens, the same in a confirmation built on Dialog:

ConsequenceConfirm buttonExample
Does somethingvariant="primary"Make public
Interrupts, but can be recoveredvariant="warning"Stop
Cannot be undonevariant="danger", and a Banner with status="destructive" in the bodyDelete agent

Deleting something large, such as an agent or a server, also asks for its name to be typed (Forms). That confirmation is a size="sm" Dialog, not an AlertDialog: its example is in Dialog.

Behavior

  • It appears and disappears without animation, over the scrim, like every centered dialog (Dialog).
  • Mounted already open (open or defaultOpen), it opens one commit after it mounted, before the first paint, as Dialog, Drawer and Lightbox do, so a confirmation mounted open together with one of them still stacks in its order over them (#proj-frontend:#121).
  • Esc and Cancel close it without acting.

Content

  • Title it with the words of the button that opened it and a question mark, since it only asks whether to go on: Delete box opens Delete box? (Writing).
  • Say in one or two sentences what happens, in plain words: "Box leaves every channel."
  • Label the confirm button with the title's verb: Stop for Stop Wug?. Keep the object when it can't be undone, on the red button: Delete agent. Label the other button Cancel (Writing).

Accessibility

  • AlertDialog wraps the Base UI Dialog and sets the alertdialog role, so screen readers announce it as an interruption. Base UI provides the focus trap, Esc and focus return.
  • AlertDialogTitle is the accessible name and AlertDialogDescription the description. Put the consequence in AlertDialogDescription, so it is announced with the title.
  • The × of AlertDialogClose is labeled "Close".

Rules

  • Put Cancel on the left and the confirm button on the right, and no other buttons.
  • Don't color the menu item that opens the dialog: the confirm button carries the color (Feedback).

API

AlertDialog

PropTypeDefault
actionsRefA ref to imperative actions. - `unmount`: Ends the closing phase of the dialog after an externally controlled closing animation finishes. Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the dialog completes closing on its own. Whether it leaves the DOM is decided by `keepMounted` on the portal. - `close`: Closes the dialog imperatively when called.RefObject<DialogRootActions | null>
childrenThe content of the dialog. This can be a regular React node or a render function that receives the `payload` of the active trigger.ReactNode | PayloadChildRenderFunction<unknown>
defaultOpenWhether the dialog is initially open.booleanfalse
defaultTriggerIdID of the trigger that the dialog is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open dialog.string
disablePointerDismissalWhether to prevent the dialog from closing on outside presses. For non-modal dialogs, this also prevents the dialog from closing when focus moves outside of it.booleanfalse
handleA handle to associate the dialog with a trigger. If specified, allows external triggers to control the dialog's open state. Can be created with the Dialog.createHandle() method.BaseDialog.Handle<unknown>
modalDetermines if the dialog enters a modal state when open. - `true`: user interaction is limited to just the dialog: focus is trapped, document page scroll is locked, and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. - `'trap-focus'`: focus is trapped inside the dialog, but document page scroll is not locked and pointer interactions outside of it remain enabled.boolean | "trap-focus"true
onOpenChangeEvent handler called when the dialog is opened or closed.(open: boolean, eventDetails: BaseDialog.Root.ChangeEventDetails) => void
onOpenChangeCompleteEvent handler called after any animations complete when the dialog is opened or closed.(open: boolean) => void
openWhether the dialog is currently open.boolean
triggerIdID of the trigger that the dialog is associated with. This is useful in conjunction with the `open` prop to create a controlled dialog. There's no need to specify this prop when the dialog is uncontrolled (that is, when the `open` prop is not set).string

AlertDialogAction

PropTypeDefault
loadingBusy: shows the spinner and blocks activation (click, Enter, Space and form submission) while keeping the button focusable. A busy button is `aria-disabled`, not natively `disabled`, so the focus a press left on it stays there and is still there when the wait ends.boolean
loadingLabelThe spinner's accessible name while `loading`: say what is happening.string
size`md` (32px) and `icon-md` for rows, cards, banners, toolbars and panel headers; `lg` and `icon-lg` (the control height) for dialog footers, forms and beside a field; `xl` for a full-width call to action; `icon-sm` (28px, a 44px hit area) for an icon-only action on a line of a row or a card, such as a comment header's More, never in a toolbar. The size follows the place: see Button › Size by place."md" | "lg" | "xl" | "icon-sm" | "icon-md" | "icon-lg" | DeprecatedButtonSize
variant"primary" | "accent" | "warning" | "danger" | "default" | "outline" | "information" | "muted" | "success" | "danger-secondary" | "danger-outline" | "ghost" | "on-frame"
focusableWhenDisabledWhether the button should be focusable when disabled.booleanfalse
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogBody

Takes the attributes of its element.

AlertDialogCancel

PropTypeDefault
size`md` (32px) and `icon-md` for rows, cards, banners, toolbars and panel headers; `lg` and `icon-lg` (the control height) for dialog footers, forms and beside a field; `xl` for a full-width call to action; `icon-sm` (28px, a 44px hit area) for an icon-only action on a line of a row or a card, such as a comment header's More, never in a toolbar. The size follows the place: see Button › Size by place."md" | "lg" | "xl" | "icon-sm" | "icon-md" | "icon-lg" | DeprecatedButtonSize
variant"primary" | "accent" | "warning" | "danger" | "default" | "outline" | "information" | "muted" | "success" | "danger-secondary" | "danger-outline" | "ghost" | "on-frame"
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue

Also takes the attributes of its element.

AlertDialogClose

PropTypeDefault
childrenReactNode
size`md` (32px) and `icon-md` for rows, cards, banners, toolbars and panel headers; `lg` and `icon-lg` (the control height) for dialog footers, forms and beside a field; `xl` for a full-width call to action; `icon-sm` (28px, a 44px hit area) for an icon-only action on a line of a row or a card, such as a comment header's More, never in a toolbar. The size follows the place: see Button › Size by place."md" | "lg" | "xl" | "icon-sm" | "icon-md" | "icon-lg" | DeprecatedButtonSize
variant"primary" | "accent" | "warning" | "danger" | "default" | "outline" | "information" | "muted" | "success" | "danger-secondary" | "danger-outline" | "ghost" | "on-frame"
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue

Also takes the attributes of its element.

AlertDialogContent

PropTypeDefault
overlayfalse | AlertDialogOverlayProps
portalPropsAlertDialogPortalProps
finalFocusDetermines the element to focus when the dialog is closed.boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void)
initialFocusDetermines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | HTMLElement | null | void)
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogDescription

PropTypeDefault
children (required)HelperText
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogFooter, AlertDialogHeader

Takes the attributes of its element.

AlertDialogOverlay

PropTypeDefault
forceRenderWhether the backdrop is forced to render even when nested.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogPortal

PropTypeDefault
containerA parent element to render the portal element into.HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null>
keepMountedWhether to keep the portal mounted in the DOM while the popup is hidden.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogTitle

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

AlertDialogTrigger

PropTypeDefault
handleA handle to associate the trigger with a dialog. Can be created with the Dialog.createHandle() method.BaseDialog.Handle<unknown>
idID of the trigger. In addition to being forwarded to the rendered element, it is also used to specify the active trigger for the dialog in controlled mode (with the DialogRoot `triggerId` prop).string
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
payloadA payload to pass to the dialog when it is opened.{}
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

Changes

  • 0.103.0 · Breaking ChangesExplanation slots take only a HelperText: FieldDescription, FormSection's description, a ChoiceList item's description, SelectItemDescription, DialogDescription, AlertDialogDescription, DrawerDescription, PopoverDescription, EmptyStateDescription, CardDescription, CardFooter, BannerDescription, DialogFooterNote (work in progress), MessageActionCardHint, MessageActionCardHeaderDescription, MessageActionCardScopeDescription and MessageActionCardActionsNote. A HelperText is made only by helperText(content, { why, about }): content is any ReactNode (a string, a formatted message, a TextLink inside a sentence), why is "consequence", "audience" or "recovery", and about names the thing the line is about. Each slot renders the content with data-why and data-about, and in development warns once when it is given anything else, which it still renders. ToastDescription, NotificationCenterItemBody, EmptyStateTitle, ListRowDescription and the status and data parts are unchanged.
  • 0.103.0 · ChangedDialogBody and AlertDialogBody draw their text in foreground, not foreground-muted.
  • 0.23.0 · ChangedButton variant="ghost", so DialogFooter, AlertDialogFooter (AlertDialogCancel) and DrawerActions: a ghost text button inside an element with data-stacked takes the ink frame of default. Dialog and alert dialog footers set data-stacked only while their buttons stack; DrawerActions sets it in a bottom or top sheet, where its buttons are always stacked, and not in a drawer from a side. Keep writing Cancel as ghost.
  • 0.8.3 · FixedA Dialog or AlertDialog opened from a sheet or another dialog draws its own, lighter scrim, so it no longer sits undimmed on the surface below. A sheet opened from a dialog does the same; a sheet over a sheet is unchanged. Nesting follows the modal roots, as in Base UI, and a modal={false} parent doesn't count.