FeedbackAvailable

Alert Dialog

An explicit confirmation step for consequential actions.

Loading example…

Installation

Add the component and its dependencies from the registry running on your computer.

terminal
npx shadcn@latest add https://brutallab.facilito.dev/r/alert-dialog.json

Usage

Import the component into your project and keep the source code under your control.

tsx
'use client';

import { useState } from 'react';
import {
  AlertDialog,
  AlertDialogTrigger,
  AlertDialogContent,
  AlertDialogHeader,
  AlertDialogTitle,
  AlertDialogDescription,
  AlertDialogFooter,
  AlertDialogCancel,
  AlertDialogAction,
} from '@/components/ui/alert-dialog';
import { Button } from '@/components/ui/button';

export default function Demo() {
  const [open, setOpen] = useState(false);
  const [message, setMessage] = useState('No changes yet.');
  return (
    <div className="grid gap-4">
      <AlertDialog open={open} onOpenChange={setOpen}>
        <AlertDialogTrigger render={<Button variant="destructive" />}>
          Reset demo
        </AlertDialogTrigger>
        <AlertDialogContent>
          <AlertDialogHeader>
            <AlertDialogTitle>Reset this example?</AlertDialogTitle>
            <AlertDialogDescription>
              This only clears the demonstration state on this page.
            </AlertDialogDescription>
          </AlertDialogHeader>
          <AlertDialogFooter>
            <AlertDialogCancel>Keep it</AlertDialogCancel>
            <AlertDialogAction
              variant="destructive"
              onClick={() => {
                setMessage('Demo reset.');
                setOpen(false);
              }}
            >
              Reset
            </AlertDialogAction>
          </AlertDialogFooter>
        </AlertDialogContent>
      </AlertDialog>
      <output className="bl-type-small">{message}</output>
    </div>
  );
}

States & interaction

Appearance, behavior and keyboard checks.

  • Check closed, open, highlighted, selected and disabled states where supported.
  • Dialogs and menus must open from the keyboard. Escape closes non-persistent overlays and returns focus to the trigger. Tooltips and hover cards must also appear on focus.
  • Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.

API Reference

BrutalLab-specific properties. Native attributes are supported as well.

PropTypeDefaultDescription
booleanuncontrolledControls visibility.
(open) => void—Responds to open and close requests.

Accessibility

Rules that should remain intact when adapting the component to a product.

Supply a title and description. Keep the cancel action available; close after the action succeeds.

Retain keyboard focus styles and test the composition with keyboard navigation.

Use className for visual customization; preserve the primitive ARIA attributes.