Components

Alert

Displays a feedback message to the user with optional title and description.

Category: Feedback / Composite

Import from @hareru/ui:

import { Alert, AlertTitle, AlertDescription } from "@hareru/ui"

Exports

ExportDescription
AlertRoot element. Renders with role="alert"
AlertTitleHeading text inside the alert
AlertDescriptionBody text inside the alert
alertVariantsCVA variant function for external use

Variants

Alert accepts a variant prop:

ValueDescription
defaultNeutral informational style (default)
destructiveError or danger style

Structure

  • AlertTitle [label]
  • AlertDescription [description]

(expected) = recommended in canonical composition, not runtime-required.

Accessibility

  • Roles: alert
  • Live region: Yes (screen readers announce changes automatically)

Usage

import { Alert, AlertTitle, AlertDescription } from "@hareru/ui"

<Alert variant="destructive">
  <AlertTitle>Error</AlertTitle>
  <AlertDescription>Something went wrong.</AlertDescription>
</Alert>

Informational alert:

<Alert>
  <AlertTitle>Heads up</AlertTitle>
  <AlertDescription>
    You can change your preferences in the settings page.
  </AlertDescription>
</Alert>

On this page