Badge

A small hand-drawn pill for status, counts, and short labels.

Overview

A Badge is a small, non-interactive pill for a short status, count, or category label — “3 unread”, “Beta”, “Success”. It carries no behaviour of its own; it just labels the thing next to it.

Anatomy

A sketchy rectangle outline drawn behind a short text label, filled with a solid, token-driven background. Six semantic variants — neutral (default), primary, success, warning, danger, info — each pair a background with the matching on-colour text and a slightly darker hand-drawn outline.

Variants & States

Badge is a static, presentational element — it has no interactive states.

State Status Notes
Hover Not implemented Badge is not interactive.
Focus Not implemented Badge is not focusable.
Disabled Not implemented —
Loading Not implemented —
Error Not implemented Use the danger variant to convey an error state.

The only variation is the semantic variant colour.

Usage

Do

  • Keep the label short — a word or two, or a small count.
  • Match the variant to meaning: success for done, danger for errors, warning for caution.
  • Add role="status" (React) or a label (WC/RN) when the badge conveys live, changing state such as an unread count.

Don't

  • Don't put interactive controls inside a Badge — it isn't focusable or clickable.
  • Don't rely on colour alone to convey meaning; include text so the state is readable without colour.
  • Don't use a Badge for long body copy — it is a label, not a container.

Accessibility

Content

A short label: a single word, a category, or a small number. For counts over a threshold, cap the text yourself (e.g. 99+) — Badge does not truncate.

Props API

React@ghds/react

PropTypeDefaultDescription
variant'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info''neutral'Semantic colour role.
...restHTMLAttributes<HTMLSpanElement>—Native <span> attributes (e.g. role, aria-label) pass through.

Web Components@ghds/web-components

PropTypeDefaultDescription
variant'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info''neutral'Semantic colour role (reflected attribute).
labelstring—When set, exposes the badge as an ARIA status region with this label.

React Native@ghds/react-native

PropTypeDefaultDescription
variant'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info''neutral'Semantic colour role.
childrenReactNode—Badge label (rendered inside a themed Text).
accessibilityLabelstring—Spoken name for icon-only or numeric badges.
testIDstring—Test handle for queries.

Code examples

// React — @ghds/react
import { Badge } from '@ghds/react/badge';

<Badge variant="success">Done</Badge>;
<!-- Web Components — @ghds/web-components -->
<script type="module">
  import '@ghds/web-components/badge';
</script>
<gh-badge variant="success">Done</gh-badge>
// React Native — @ghds/react-native
import { Badge } from '@ghds/react-native/badge';

<Badge variant="success">Done</Badge>;

Live Demo

React @ghds/react

Web Components @ghds/web-components

neutral primary success warning danger info