Badge
Marks an item with a small label such as a category or a state, rendered as a small Tag.
Em análise
variant
<Badge variant="info">Em análise</Badge>Which one to use
Badge, Tag, Chip and Status badge look alike. They answer different questions.
| Component | What it is | Interactive | Example |
|---|---|---|---|
| Badge (this page) | A small label, always the sm size. Wraps Tag. |
No | “Novo” next to a menu item. |
| Tag | A label in three sizes, with an optional icon. | No | “Aprovado” with a check icon. |
| Chip | An applied filter or selected value you can remove. | Yes | “Revisor: Marina Costa” with ×. |
| Status badge | A processing status picked from a backend code. | No | “Processando” with an icon. |
If you are writing new code and need an icon or a larger size, use Tag. Use Badge to keep existing code that already imports it.
When to use
- To mark a list item or a row with a short category or state.
- Inline in text, with
as="span", to flag a part of a sentence.
When not to use
- A processing status from the backend. Use Status badge.
- A filter or value the user can remove. Use Chip.
- A label that needs an icon or a size above
sm. Use Tag. - A count of unread items. Use Notification badge.
Variants
Variants are the variants of Tag. When none is passed, the badge is default.
Novo
Padrão
Arquivado
Falhou
Em análise
Destaque
Concluído
Pendente
| Variant | Use for |
|---|---|
default |
Neutral category or tag. |
primary |
A brand highlight. |
accent |
Something new. |
info |
Informational state, such as “Em análise”. |
success |
Completed or approved. |
warning |
Needs attention, such as “Pendente”. |
error |
Failed or rejected. |
disabled |
Inactive or archived items. |
Legacy variants
destructive, outline and secondary are older shadcn names. They are mapped to a Tag variant, shown after the arrow. Do not use them in new code.
destructive → error
outline → default
secondary → default
Examples
Use as="span" inside a sentence.
Contestação Pendente de revisão
Content
- One or two words: “Novo”, “Pendente”, “Em análise”.
- Sentence case, no period.
- Describe the state, not the action: “Pendente”, not “Aguardar”.
Do and don’t
Pendente
Rejeitado
Accessibility
- It renders a static
div(a Tag). It has no role and is not focusable. - The text is the content: color is never the only signal. Write the state as a word (“Pendente”) instead of relying on the warning color.
- Colors come from the semantic Tag tokens. Check contrast in Light, Dark and Darker.
- A badge that sits inside a sentence should use
as="span": adivinside a paragraph is invalid HTML. - Do not make a badge clickable. For an action, use Button; for a removable filter, use Chip.
Code
import { Badge } from "@repo/ui/badge";
<Badge variant="warning">Pendente</Badge>
// Inline in text
<p>
Contestação <Badge as="span" variant="info">Em análise</Badge>
</p>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
as | React.ElementType | div | Element to render, for example `span`. Defaults to a `div` (a `Tag`) |
variant | "accent" | "default" | "disabled" | "error" | "info" | "primary" | "success" | "warning" | "destructive" | "outline" | "secondary" | default | Tag variant. The legacy names `destructive`, `outline` and `secondary` are mapped to a Tag variant |
Known issues
| Issue | Effect |
|---|---|
legacyVariantMap maps outline and secondary to Tag default. |
A badge with variant="outline" renders as default: no outline. Tag’s real outline variant cannot be reached through Badge. |
Badge always renders Tag at the sm size and passes no icon. |
No icon and no larger size. Use Tag for those. |
With as other than div, props go to the child element, not to Tag. |
The two paths build the element differently: with div, props go to the Tag; otherwise they go to the custom element. |
BadgeProps is an interface. |
Code only: the repository prefers type. |