Feedback

Alert

Banner-style message for status, errors, and notices. Compose <Alert> with <AlertTitle> + <AlertDescription> and optionally <AlertIcon>.

Preview
01 Installation

Install

Pull Alert from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Alert } from "@brika/clay";
tsxGranular1 line
import { Alert } from "@brika/clay/components/alert";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxAlert.tsx18 lines
'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>
  );
}
03 Examples

Alert, every way

Dismissible

Alert with a dismiss button, controlled visibility via useState.

Variants

All five semantic variants stacked, each with matching icon and copy.

With Icon

Error alert with a leading icon, compose AlertIcon before the text slots.

04 Accessibility

Accessibility

  • Root carries role="alert" so live-region announcements fire on mount.
  • AlertTitle and AlertDescription are sibling elements, AT reads them as one block.
  • Icon inside AlertIcon is marked aria-hidden; the text content carries the meaning.
05 Tokens 15 theme-overridable

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
ColorFill, border, and text colors.11
  • --alert-accentcolorcurrentColor
    components.alert.accent

    Accent 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.background

    Background 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.foreground

    Body 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.borderColor

    Border 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.descriptionForeground

    Text color of the alert description block; muted by default so the title stays the visual anchor.

  • --alert-destructive-titlecolorvar(--destructive)
    components.alert.destructiveTitle

    Title 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.closeForeground

    Resting text color of the close (X) button.

  • --alert-close-foreground-hovercolorvar(--foreground)
    components.alert.closeForegroundHover

    Hover text color of the close (X) button.

  • --alert-close-bg-hovercolorcolor-mix(in oklch, var(--foreground) 5%, transparent)
    components.alert.closeBgHover

    Hover background fill of the close (X) button.

  • --alert-close-ringcolorvar(--ring)
    components.alert.closeRing

    Focus ring color of the close (X) button.

  • --alert-tint-basecolorvar(--background)
    components.alert.tintBase

    Base color the per-variant accent is mixed into. Defaults to the page surface for opaque tints; set to `transparent` for translucent / glass variants.

GeometrySizes, lengths, and corner radii.1
  • --alert-radiusradiusvar(--radius-container)
    components.alert.radius

    Alert corner radius.

ElevationDrop shadow and depth.1
  • --alert-backdrop-blurblur0px
    components.alert.backdropBlur

    Backdrop blur applied to the alert. Set non-zero alongside a translucent `tint-base` (e.g. `transparent`) for a glass variant.

StateHover / pressed / disabled overlays.2
  • --alert-tint-bg-amountopacity12%
    components.alert.tintBgAmount

    Accent percentage mixed into the tinted-variant background. Higher values produce more saturated bg fills.

  • --alert-tint-border-amountopacity40%
    components.alert.tintBorderAmount

    Accent 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.

jsonmy-theme.json12 lines
{
  "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.

06 API reference

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
  • string
    Additional 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
  • string
    Additional classes merged onto the close button.

<AlertDescription />

1 prop
  • string
    Additional classes merged onto the description block.

<AlertIcon />

1 prop
  • string
    Additional classes merged onto the icon slot.

<AlertTitle />

1 prop
  • string
    Additional classes merged onto the title row.