Talisman LogoTalisman Logo Design System
Browse documentation
Components

Alert

Shows an inline message about the state of the page or a task, with an icon, a title, a description and optional actions.

Stableimport { Alert } from "@repo/ui/alert";Source
layout
variant
<Alert layout="vertical" variant="warning" />

When to use

  • To explain the state of the page or of a task: a failed generation, missing documents, a saved draft.
  • To warn about something the user must know before or while acting.
  • To confirm a result that stays on the page, such as “Contestação enviada”.

When not to use

  • A short confirmation that can disappear. Use a toast (Sonner).
  • A decision that blocks the flow. Use Alert dialog or Dialog.
  • A label on a single item. Use Tag, or Status badge for processing status.
  • Progress of a running task. Use Progress or Loader.

Variants

When no variant is passed, the alert is neutral. default and destructive still work but are deprecated aliases of neutral and critical.

Variant Use for
neutral Default. General notes with no urgency.
information Something the user should know that needs no action.
success A task or operation finished.
warning Something may go wrong or needs attention soon.
critical An error or a blocked operation. The user must act.
accent A product announcement, such as a new feature.

Layouts

vertical stacks the icon, title and description. horizontal fits one line of text with the actions on the right.

Examples

Add actions with AlertActions. Keep them to one or two buttons.

A short message does not need a title.

For a message that is not urgent, pass role="status".

Rascunho automático
As alterações são salvas automaticamente a cada minuto.

Content

  • Title: what happened, in 2 to 5 words (“Falha na geração”).
  • Description: why it happened and what the user can do. One or two sentences.
  • Name the object: “Não foi possível gerar a contestação do processo 0001234-56.2024.8.26.0100”.
  • Put the next step in AlertActions with a verb: “Tentar novamente”.

Do and don’t

DoPair the color with an icon and a text. The message reads without color.
Don'tDon't rely on color only. A user who cannot tell the colors apart misses the severity.
DoUse success for a result that stays visible.
Don'tDon't use critical for good news. The color sets the expectation.

Accessibility

  • It renders a div with role="alert", an assertive live region: screen readers interrupt to read it when it appears. Use it for errors and urgent messages.
  • For information that is not urgent, override with role="status" (polite). The role is placed before {...props}, so it can be replaced.
  • Variant colors are never the only signal: always add an icon and text. Icons placed as direct svg children get the variant color; mark them aria-hidden="true" because the text carries the meaning.
  • AlertTitle renders an h5. Check that it fits the heading order of the page.
  • Actions are normal buttons: Tab reaches them in reading order.
  • The component does not move focus. Do not use it for content the user must act on before continuing.

Code

import {
  Alert,
  AlertActions,
  AlertDescription,
  AlertTitle,
} from "@repo/ui/alert";

<Alert variant="critical">
  <OctagonAlert aria-hidden="true" />
  <AlertTitle>Falha na geração</AlertTitle>
  <AlertDescription>Não foi possível gerar a contestação.</AlertDescription>
  <AlertActions>
    <Button size="xxs" variant="critical">
      Tentar novamente
    </Button>
  </AlertActions>
</Alert>;

Props

Alert
PropTypeDefaultDescription
layout"horizontal" | "vertical"verticalVertical stacks icon, title and description. Horizontal puts them in one row with the actions on the right
variant"accent" | "critical" | "information" | "neutral" | "success" | "warning"neutralSemantic color of the message
AlertActions
PropTypeDefaultDescription
childrenReactNode—Buttons or links for the next step. Aligned to the right in the horizontal layout.
AlertTitle
PropTypeDefaultDescription
childrenReactNode—Short title. Renders an h5 with the labelSm style.
AlertDescription
PropTypeDefaultDescription
childrenReactNode—Message text. Renders a div with the paragraphSm style.

Known issues

Issue Effect
Alert always sets role="alert" by default. Every alert is announced assertively. Non-urgent messages interrupt screen readers unless role="status" is passed.
The icon is not part of the component: it must be a direct svg child. An icon wrapped in another element loses the variant color and the vertical positioning.
AlertTitle is a fixed h5. It can break the heading order of a page. The component accepts no as prop, so the level cannot change.
The deprecated variants default and destructive stay in the type. Editors still suggest them. They render the same as neutral and critical.
Edit this page on GitHub