Alert
Shows an inline message about the state of the page or a task, with an icon, a title, a description and optional actions.
Documentos pendentes
Faltam documentos obrigatórios para concluir esta tarefa.
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.
Novidade no editor
A nova versão do modelo de contestação já está disponível.
Falha na geração
Não foi possível gerar a petição. Tente novamente.
Sincronização em andamento
O processo será sincronizado com o tribunal em instantes.
Rascunho automático
As alterações são salvas automaticamente a cada minuto.
Contestação enviada
A contestação foi enviada para revisão.
Documentos pendentes
Faltam documentos obrigatórios para concluir esta tarefa.
| 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.
Sincronização em andamento
O processo será sincronizado com o tribunal em instantes.
O processo será sincronizado com o tribunal em instantes.
Examples
Add actions with AlertActions. Keep them to one or two buttons.
Falha na geração
Não foi possível gerar a contestação do processo 0001234-56.2024.8.26.0100.
A short message does not need a title.
Alterações salvas com sucesso.
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
AlertActionswith a verb: “Tentar novamente”.
Do and don’t
Falha na geração
Não foi possível gerar a petição.
Não foi possível gerar a petição.
Contestação enviada para revisão.
Contestação enviada para revisão.
Accessibility
- It renders a
divwithrole="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). Theroleis 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
svgchildren get the variant color; mark themaria-hidden="true"because the text carries the meaning. AlertTitlerenders anh5. 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| Prop | Type | Default | Description |
|---|---|---|---|
layout | "horizontal" | "vertical" | vertical | Vertical stacks icon, title and description. Horizontal puts them in one row with the actions on the right |
variant | "accent" | "critical" | "information" | "neutral" | "success" | "warning" | neutral | Semantic color of the message |
AlertActions| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Buttons or links for the next step. Aligned to the right in the horizontal layout. |
AlertTitle| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Short title. Renders an h5 with the labelSm style. |
AlertDescription| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | 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. |