Alert dialog

Alert dialog composes Base UI’s alert dialog primitives for confirmations that need an explicit decision.

import { AlertDialog } from "density-base-ui";

export default function AlertDialogExample() {
  return (
    <AlertDialog.Root>
      <AlertDialog.Trigger density-emphasis="primary">
        Delete report
      </AlertDialog.Trigger>
      <AlertDialog.Portal>
        <AlertDialog.Backdrop className="alert-dialog-example-backdrop" />
        <AlertDialog.Popup className="alert-dialog-example-popup">
          <AlertDialog.Title className="alert-dialog-example-title">
            Delete quarterly report?
          </AlertDialog.Title>
          <AlertDialog.Description className="alert-dialog-example-description">
            This removes the report from everyone&apos;s dashboard. This action
            cannot be undone.
          </AlertDialog.Description>
          <div className="alert-dialog-example-actions">
            <AlertDialog.Close>Cancel</AlertDialog.Close>
            <AlertDialog.Close density-emphasis="primary">
              Delete report
            </AlertDialog.Close>
          </div>
        </AlertDialog.Popup>
      </AlertDialog.Portal>
    </AlertDialog.Root>
  );
}

Props

Prop Attribute Values Default
AlertDialog.Trigger density-presentation data-dn-presentation button button
AlertDialog.Trigger density-emphasis data-dn-emphasis primary, secondary, outline, ghost secondary
AlertDialog.Trigger density-size data-dn-size 2xs, xs, sm, md, lg, xl, 2xl, 3xl md
AlertDialog.Close density-presentation data-dn-presentation button button
AlertDialog.Close density-emphasis data-dn-emphasis primary, secondary, outline, ghost ghost
AlertDialog.Close density-size data-dn-size 2xs, xs, sm, md, lg, xl, 2xl, 3xl md
AlertDialog.Popup density-presentation data-dn-presentation card card
AlertDialog.Popup density-level data-dn-level 1, 2, 3, 4, 5, 6, 7 3
Other AlertDialog parts Mixed Base UI alert dialog props None