Install
Pull Alert Dialog from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { AlertDialog } from "@brika/clay";import { AlertDialog } from "@brika/clay/components/alert-dialog";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
'use client';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@brika/clay/components/alert-dialog';
import { Button } from '@brika/clay/components/button';
/** Destructive confirmation dialog, blocks all interaction until the user resolves it. */
export default function AlertDialogDefaultDemo() {
return (
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">Delete account</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Delete this account?</AlertDialogTitle>
<AlertDialogDescription>
This action is permanent. All your projects, history, and data will
be removed and cannot be recovered.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction variant="destructive">Delete account</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}Alert Dialog, every way
Loading
Controlled dialog where the confirm button shows a loading state while the action runs.
Accessibility
- Unlike
Dialog,AlertDialogdoes not close on backdrop click, the user must explicitly respond. - Focus defaults to the cancel action on open, reducing accidental destructive confirmations.
-
AlertDialogTitleandAlertDialogDescriptionare announced immediately when the dialog opens. - Only two outcomes are possible: confirm or cancel. Do not add other interactive elements.
Theme tokens
Every CSS variable Alert Dialog reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Alert Dialog
without touching component code.
Alert Dialog tokens
2 tokens--alert-dialog-media-containercolorvar(--muted)components.alertDialog.mediaContainerBackground of the `<AlertDialogMedia>` thumbnail / icon tile shown above the title.
--alert-dialog-border-colorcolorvar(--border)components.alertDialog.borderColorBorder color drawn around the `<AlertDialogContent>` surface. Defaults to the theme border color.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.alertDialog, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"alertDialog": {
"mediaContainer": "var(--muted)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-alert-dialog-…) — see the
chips on each token row.
API reference
Props specific to Alert Dialog. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<AlertDialog />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogAction />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogCancel />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogContent />
1 prop- sizedefault
'default''default' | 'sm'Dialog max-width preset.
<AlertDialogDescription />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogFooter />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogHeader />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogMedia />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogOverlay />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogPortal />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogTitle />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.
<AlertDialogTrigger />
passthroughNo wrapper-specific props, all attributes pass through to the underlying primitive.