Documentation

Badge

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

Web + MobileStableData display

Web and mobile — the same component for React and React Native. Stable: its API only changes in a major version.

When to use

  • 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.

When not to use

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

Installation

Install

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

Styles

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

Import

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

Examples

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

PropTypeDefaultDescription
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).

Accessibility

  • 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.

Best practices

  • 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.

Generated from the code of @krizaka/ui 2.0.0-beta.6: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page