Skip to content

Alert

An inline callout with title, description and tone variants.

For a message that belongs to a place on the page and stays there. An alert has role="alert", so a screen reader reads it the moment it is added to the page: keep it for what the person must know, and use @khaeli/sonner for a message that comes and goes.

Default

With icon

Destructive

With an action

Installation

npx shadcn@latest add @khaeli/alert

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

Registry items
npm packages
  • class-variance-authority ^0.7.1

Accessible name

  • An alert needs no label: it is read by its content, the title first.
  • An icon is decorative. The destructive variant differs from the default by colour alone, so let the title and the icon say that something went wrong.
  • A button in AlertAction is read apart from the title: when its text does not say what it acts on, name it in full with aria-label (Remind about invoice INV-1040).

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/alert.json