Badge
A short label for a status, a count or a category. Quiet by default; a status hue only when the badge reports one.
Usage
import { Badge, BadgeDot } from 'nyctoui/badge'
<Badge tone="green">
<BadgeDot />
Deployed
</Badge>A badge is 20px tall with 12px medium text, so it sits on a row beside 14px text or inside a list item without changing its height. It isn’t interactive. For something people press, use a Button; for a set of choices, a SegmentedControl.
ui-sdk has no badge, since it has no behavior to share. It’s built with renderElement, so it takes the same render prop as other parts: pass render={<Link to="…" />} to make it a link.
Good for
- A deploy or build list in a CI dashboard, marking runs Failed or Canceled.
- An issue tracker row showing the label, such as Bug or Design.
- A billing page showing an invoice as Overdue.
- A version list in package or API docs, marking one as Latest or Deprecated.
Examples
Tones
neutral is for categories and counts. The hues are for status: blue for information, green for success, yellow and orange for warnings, red for failures. Each fills with a tint of its color, so it reads on cards and popovers as well as the page, and its text uses a darker ink of the same hue that stays legible at 12px.
Outline
variant="outline" draws a hairline instead of a fill, for a marker that should sit back further, like a version’s Default or Latest.
With an icon
Put a Tabler icon before the text at size={12}, the one place icons are drawn smaller than 16px, so they fit the 20px badge. Mark it aria-hidden; the text carries the meaning.
In a row
Beside a heading and a small button, as on a settings page.
Accessibility
A badge is plain text. Color alone never carries the status: write it out (“Failed”, not only a red dot), so it reads the same to people who can’t tell the hues apart and to screen readers. The dot and icons are hidden from assistive technology.
Best practices
- Badge only the states people need to notice or act on, such as Failed, Overdue or Needs review. When nothing needs doing, plain text is enough.
- Keep the hues for status: red for failures, orange and yellow for warnings, green for success, blue for information. Categories use
neutral. - Keep the label to one or two words, and put any detail in the text beside it.
- Write the status out next to any dot or icon, so it doesn’t rely on color.
- Put a green “Active” badge on every healthy row. When every row has one, none of them stands out; badge the exceptions.
- Use a badge for metadata like dates, durations or counts of things. Write those as secondary text.
- Make a badge the only way to act on something. It’s read-only; give the action a button or a link.
API reference
Badge
A <span> by default. Other props go to the element.
| Prop | Type | Default |
|---|---|---|
toneColor. Use a hue only for status. | 'neutral' | 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'neutral' |
variantA tinted fill, or a hairline on a transparent fill. | 'soft' | 'outline' | 'soft' |
renderRenders another element, such as a link, with the badge’s props. | ReactElement | (props) => ReactElement | — |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
BadgeDot
A 6px <span> dot in the badge’s color, hidden from assistive technology.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |