Alert
Banner-style message for status, errors, and notices. Compose <Alert> with <AlertTitle> + <AlertDescription> and optionally <AlertIcon>.
Install
Pull Alert from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Alert } from "@brika/clay";import { Alert } from "@brika/clay/components/alert";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
'use client';
import {
Alert,
AlertDescription,
AlertTitle,
} from '@brika/clay/components/alert';
/** Plain alert with title and description, the baseline composition. */
export default function AlertDefaultDemo() {
return (
<Alert className="w-full max-w-md">
<AlertTitle>Heads up</AlertTitle>
<AlertDescription>
Your free trial ends in 3 days. Upgrade to keep access to all features.
</AlertDescription>
</Alert>
);
}Alert, every way
Accessibility
- Root carries
role="alert"so live-region announcements fire on mount. -
AlertTitleandAlertDescriptionare sibling elements, AT reads them as one block. - Icon inside
AlertIconis markedaria-hidden; the text content carries the meaning.
Theme tokens
Every CSS variable Alert 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
without touching component code.
Alert tokens
15 tokens--alert-accentcolorcurrentColorcomponents.alert.accentAccent color the variant icon picks up. Each variant overrides this inline (`[--alert-accent:var(--destructive)]` etc.); the default falls back to `currentColor` so a custom variant inherits the alert label color.
--alert-backgroundcolorvar(--background)components.alert.backgroundBackground fill of the default (untinted) alert variant. Tinted variants override the bg via inline `color-mix()` and ignore this slot.
--alert-foregroundcolorvar(--foreground)components.alert.foregroundBody text color shared by every alert variant; the title and surface inherit this so swapping it retints the whole alert label.
--alert-border-colorcolorvar(--border)components.alert.borderColorBorder color of the default (untinted) alert variant. Tinted variants override the border via inline `color-mix()` and ignore this slot.
--alert-description-foregroundcolorvar(--muted-foreground)components.alert.descriptionForegroundText color of the alert description block; muted by default so the title stays the visual anchor.
--alert-destructive-titlecolorvar(--destructive)components.alert.destructiveTitleTitle text color when the alert is the `destructive` variant. Lifted into a slot so themes can dial the title saturation independently of the destructive role token.
--alert-close-foregroundcolorvar(--muted-foreground)components.alert.closeForegroundResting text color of the close (X) button.
--alert-close-foreground-hovercolorvar(--foreground)components.alert.closeForegroundHoverHover text color of the close (X) button.
--alert-close-bg-hovercolorcolor-mix(in oklch, var(--foreground) 5%, transparent)components.alert.closeBgHoverHover background fill of the close (X) button.
--alert-close-ringcolorvar(--ring)components.alert.closeRingFocus ring color of the close (X) button.
--alert-tint-basecolorvar(--background)components.alert.tintBaseBase color the per-variant accent is mixed into. Defaults to the page surface for opaque tints; set to `transparent` for translucent / glass variants.
--alert-radiusradiusvar(--radius-container)components.alert.radiusAlert corner radius.
--alert-backdrop-blurblur0pxcomponents.alert.backdropBlurBackdrop blur applied to the alert. Set non-zero alongside a translucent `tint-base` (e.g. `transparent`) for a glass variant.
--alert-tint-bg-amountopacity12%components.alert.tintBgAmountAccent percentage mixed into the tinted-variant background. Higher values produce more saturated bg fills.
--alert-tint-border-amountopacity40%components.alert.tintBorderAmountAccent percentage mixed into the tinted-variant border. Usually higher than the bg amount so the edge stays defined.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.alert, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"alert": {
"radius": "var(--radius-container)"
}
}
}
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-…) — see the
chips on each token row.
API reference
Props specific to Alert. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
<Alert />
2 props- stringAdditional Tailwind / utility classes merged on top of the variant classes.
- variantdefault
'default''default' | 'destructive' | 'info' | 'warning' | 'success'Visual treatment:default(quiet),destructive(error tint),info/warning/success(semantic data colors).
<AlertClose />
1 prop- stringAdditional classes merged onto the close button.
<AlertDescription />
1 prop- stringAdditional classes merged onto the description block.
<AlertIcon />
1 prop- stringAdditional classes merged onto the icon slot.
<AlertTitle />
1 prop- stringAdditional classes merged onto the title row.