Badge
A short status or label: a tone, two sizes, an optional dot that can pulse.
Web et mobile — le même composant pour React et React Native. Stable : son API ne change qu’à une version majeure.
Quand l’utiliser
- To label the state of an item: paid, pending, new, live, ending soon.
- On a media (
tone="scrim"): a duration, a quality, a live marker. - With a
dot(andpulse) for something happening now.
Quand ne pas l’utiliser
Installation
Installer
npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcssStyles
@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";Importer
import { Badge } from "@krizaka/ui/badge";Exemples
Neutral
The default tone.
New
import { Badge } from "@krizaka/ui/badge";
export default function BadgeNeutral() {
return <Badge>New</Badge>;
}Accent
To highlight: new, featured.
New
import { Badge } from "@krizaka/ui/badge";
export default function BadgeAccent() {
return (
<Badge tone="accent" dot>
New
</Badge>
);
}Success
A good state: paid, verified.
Paid
import { Badge } from "@krizaka/ui/badge";
export default function BadgeSuccess() {
return (
<Badge tone="success" dot>
Paid
</Badge>
);
}Warning
A state that needs attention soon.
Pending
import { Badge } from "@krizaka/ui/badge";
export default function BadgeWarning() {
return (
<Badge tone="warning" dot>
Pending
</Badge>
);
}Danger with pulse
Urgent, happening now: the dot pulses.
Ends soon
import { Badge } from "@krizaka/ui/badge";
export default function BadgeDanger() {
return (
<Badge tone="danger" dot pulse>
Ends soon
</Badge>
);
}On a media
tone="scrim": the veil and the text are identical in both themes.
4K
import { Badge } from "@krizaka/ui/badge";
// On a media: the veil and the text are invariant, identical in both themes.
export default function BadgeScrim() {
return (
<div className="flex h-24 w-40 items-start bg-media p-2.5">
<Badge tone="scrim">4K</Badge>
</div>
);
}Medium
size="md" for a badge next to a heading.
Featured
import { Badge } from "@krizaka/ui/badge";
export default function BadgeMedium() {
return (
<Badge tone="accent" size="md">
Featured
</Badge>
);
}Props
| Prop | Type | Défaut | Description |
|---|---|---|---|
dot | boolean | — | A small dot before the text, in the tone's colour (pulsing with pulse). |
pulse | boolean | — | Makes the dot pulse (stopped under reduced motion). |
size | "sm" | "md" | sm | sm · md. |
tone | "success" | "warning" | "danger" | "neutral" | "accent" | "scrim" | neutral | neutral · accent · success · warning · danger (soft tints, the text stays a text role) · scrim (on a media). |
Accessibilité
- A plain
<span>: its text is read with the content around it; the dot is decorative. - The colour is never the only signal: the words say the state.
- The pulse stops under
prefers-reduced-motion.
Bonnes pratiques
- One or two words: a badge is scanned, not read.
- Keep the tone meaningful:
success,warning,dangerfor states;accentto highlight;neutralotherwise. pulseonly for what is live: a page full of pulsing dots says nothing.
Composants liés
Générée depuis le code de @krizaka/ui 2.0.0-beta.6 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub