Alert

Displays a short, important message to attract the user's attention.

Default

The default alert is filled with the primary color.

tsx

import { Alert } from "@hummingbirdui/react";

export default function AlertDefault() {
  return <Alert>A simple primary alert with important information.</Alert>;
}

Variants

The variant prop changes the visual style: filled (default), subtle, or outline.

tsx

import { Alert } from "@hummingbirdui/react";

export default function AlertVariants() {
  return (
    <div className="flex flex-col gap-3">
      <Alert variant="filled">A filled alert.</Alert>
      <Alert variant="subtle">A subtle alert.</Alert>
      <Alert variant="outline">An outline alert.</Alert>
    </div>
  );
}

Colors

The color prop conveys intent with primary (default), neutral, secondary, info, success, warning, or danger.

tsx

import { Alert } from "@hummingbirdui/react";

export default function AlertColors() {
  return (
    <div className="flex flex-col gap-3">
      <Alert color="neutral">A neutral alert.</Alert>
      <Alert color="primary">A primary alert.</Alert>
      <Alert color="secondary">A secondary alert.</Alert>
      <Alert color="info">An info alert.</Alert>
      <Alert color="success">A success alert.</Alert>
      <Alert color="warning">A warning alert.</Alert>
      <Alert color="danger">A danger alert.</Alert>
    </div>
  );
}

With icon

AlertIcon renders a leading icon.

tsx

import { Alert, AlertIcon } from "@hummingbirdui/react";
import { CircleCheck } from "lucide-react";

export default function AlertWithIcon() {
  return (
    <Alert color="success">
      <AlertIcon>
        <CircleCheck className="size-5" />
      </AlertIcon>
      Your changes have been saved successfully.
    </Alert>
  );
}

API Reference

Alert

PropTypeDefaultDescription
variant"filled" | "subtle" | "outline""filled"Visual style of the alert.
color"neutral" | "primary" | "secondary" | "info" | "success" | "warning" | "danger""primary"Color theme of the alert.
asChildbooleanfalseRender as a child element instead of the default.
classNamestringAdditional classes merged with the generated classes.

AlertIcon

PropTypeDefaultDescription
asChildbooleanfalseRender as a child element instead of the default.
classNamestringAdditional classes merged with the generated classes.

Styling

Hummingbird React alert is styled entirely through Hummingbird's utility classes and CSS variables.

  • See the full list of available alert classes in the Class overview.
  • Visit the CSS Variables documentation to explore all available variables.