Documentation

Badge

A short status or label: a tone, two sizes, an optional dot that can pulse.

Web + MobileStableAffichage de données

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 (and pulse) for something happening now.

Quand ne pas l’utiliser

  • For something the user can click or select.À la place : Chip
  • For a message the user must read.À la place : Alert
  • For a key figure with a trend.À la place : Stat

Installation

Installer

npm install @krizaka/ui@beta @krizaka/tailwind@beta @krizaka/tokens@beta tailwindcss

Styles

@import "tailwindcss";
@import "@krizaka/tailwind";
@import "@krizaka/ui/tailwind.css";

Importer

import { Badge } from "@krizaka/ui/badge";

Exemples

Neutral

The default tone.

New

Accent

To highlight: new, featured.

New

Success

A good state: paid, verified.

Paid

Warning

A state that needs attention soon.

Pending

Danger with pulse

Urgent, happening now: the dot pulses.

Ends soon

On a media

tone="scrim": the veil and the text are identical in both themes.

4K

Medium

size="md" for a badge next to a heading.

Featured

Props

PropTypeDéfautDescription
dotboolean—A small dot before the text, in the tone's colour (pulsing with pulse).
pulseboolean—Makes the dot pulse (stopped under reduced motion).
size"sm" | "md"smsm · md.
tone"success" | "warning" | "danger" | "neutral" | "accent" | "scrim"neutralneutral · 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, danger for states; accent to highlight; neutral otherwise.
  • pulse only for what is live: a page full of pulsing dots says nothing.

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

Sur cette page