Badge
Badge is a small mark that stays on a thing until you look at it, such as the number on an app icon or an unread dot.
A badge is a small mark that stays on something until people look at it, such as the number on an app icon or the unread dot on a tab. With no content, it is a dot. With a number in it, it is a pill.
Use a badge to count items or to point at something new. Use a Chip for a word, such as Paid or Failed, and for a quieter mark. Use a Notice when a condition needs a sentence.
A badge always has a strong colour, and it has no emphasis. tone says what it means: the default, accent, means that something is there, and destructive means that something needs attention. Your app maps its own meanings onto a tone, for example a failed payment onto destructive.
Without a size, a badge scales with the line it sits in, so a badge in a tab label and a badge on a large avatar have the same shape at different sizes. Set size only when the badge stands alone.
A badge has no position of its own. Put it in a line of text or in a Row's trailing slot, or pass it to an Avatar's badge prop to place it on the avatar's corner.
A dot is only a colour, so it needs an aria-label that says what it means. A count is its own accessible name, so its aria-label is optional. A badge with no content and no label renders nothing, which is why {count > 0 && count} hides it at zero.
- Chip when the label states the current state of the thing beside it, such as Draft.
Props
Generated from the types. It lists what this component DECLARES: a prop that arrives from a shared type or from the platform is real and is not repeated here.
| Prop | Type | What it does |
|---|---|---|
aria-label | string | The accessible name of the dot, such as "New messages". |
children? | undefined | No content. |
size? | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | The text size step of the badge, from 1 to 9. |
tone? | "neutral" | "accent" | "destructive" | "blue" | "green" | "orange" | "amber" | "pink" | "purple" | "success" | "warning" | "info" | The meaning of the badge, which sets its colour. |
It also takes every prop of a <span>.
emphasis— A badge is always strong, because its job is to catch attention until people look. For a quieter mark with a word in it, use a Chip.- Built-in status words — Words such as Online or Overdue belong to your product, so your app maps each one to a tone. If the word itself must show, use a Chip.
- An unnamed dot — A dot with no content is only a colour, and some people cannot see the colour. The type therefore requires an
aria-labelthat says what the dot means. - A position of its own — The element that holds the badge decides where it goes. To pin a badge to the corner of an avatar, use the Avatar's
badgeprop.