- Docs
- Components
- Data display
Badge
A short, static status or count: one or two words. The word carries the meaning, the tone reinforces it.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<span>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Import
// From the package: a build keeps only what it uses.
import { Badge } from "@qeetrix/react";
// Or from its own path.
import { Badge } from "@qeetrix/react/badge";02
Props
And every native attribute of the element it renders.
| Prop | Type | Default | What it does |
|---|---|---|---|
tone | "neutral" | "brand" | "info" | "success" | "warning" | "danger" | "neutral" | Reinforces the word. |
variant | "subtle" | "solid" | "subtle" | Subtle, the tone's tint; solid, its bold fill, AA in every tone and scheme. |
size | "md" | "sm" | "md" | 20px or 16px. |
icon | IconSource | — | A leading 12px icon (--qx-size-icon-2xs), sharp, decorative. |
children | ReactNode | — | The word or the count. |
03
Parts
Each part carries a data-slot, for tests and placement.
| data-slot | Element | What it is |
|---|---|---|
badge | <span> | data-tone, data-variant, data-size. |
badge-icon | <svg> | aria-hidden. |
badge-label | <span> | The text, truncated. |
04
From a status
Map each status to its tone once, so every list agrees.
const tone = { Active: "success", Invited: "info", Blocked: "danger" } as const;
<Badge tone={tone[user.status]}>{user.status}</Badge>