Badge

A small label that shows the status, category or count of something.

import { Badge } from '@halo-ds/react';

When to use it

Use a badge to tag an item with a short status like Active or Beta, or to show a count like 3 unread. Badges are read-only: to filter or remove something, use a Tag instead. Pick the colour for its meaning, the style for how much it should stand out, and the size to match the text around it.

Do

  • Keep labels to one or two words, in sentence case.
  • Use the same colour for the same status everywhere in your product.
  • Use Soft in lists and tables; save Solid for the one thing that must stand out.
  • Cap big counts, for example 99+.

Don't

  • Rely on colour alone; the label must say what it means.
  • Make badges clickable; use a Tag or a Button instead.
  • Put sentences in a badge; use helper text instead.
  • Line up several Solid badges side by side.

Badge or Tag?

They look alike, but a badge only shows information. A tag is something people can act on.

  • Badge: Shows a status, category or count. Read-only: nothing to click, nothing to remove. Sits next to the thing it describes.
  • Tag: Something people chose or can act on, like a filter or a label they added. Can be clicked, selected or removed with an ×. Lives in inputs, filter bars and lists of choices.

Props

Badge props

PropTypeWhat it does
color`BadgeColor \undefined`What the badge means. Figma: Colour.
variant`BadgeVariant \undefined`How much it stands out: soft (default), solid or outline. Figma: Style.
size`BadgeSize \undefined`XS 16, S 20, M 24, L 28. Figma: Size.
dot`boolean \undefined`A small dot before the label, for statuses. Figma: Show dot.
iconReactNodeAn icon before the label. Figma: Show icon and Icon.
count`number \undefined`Shows a number instead of children, capped at max. Give the badge an aria-label such as "3 unread messages".
max`number \undefined`The highest count shown before it becomes, for example, 99+.
childrenReactNodeThe label. Figma: Label.
classNames`Partial<Record<BadgePart, string>> \undefined`Extra class names for the parts inside the component, by part name, like { header: 'my-header' }.
styles`Partial<Record<BadgePart, CSSProperties>> \undefined`Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }.

It also takes the usual HTML attributes for its element.

Examples

Overview

import { Badge } from '@halo-ds/react';

export default function Example() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8, justifyContent: 'center' }}>
      <Badge>Draft</Badge>
      <Badge color="information">In review</Badge>
      <Badge color="success" dot>Live</Badge>
      <Badge color="warning">Due soon</Badge>
      <Badge color="error">Overdue</Badge>
      <Badge color="brand" variant="solid">New</Badge>
      <Badge color="error" variant="solid" count={12} />
    </div>
  );
}

Colours and styles

Six colours in three styles. Pick the colour for its meaning, not for decoration.

import { Badge } from '@halo-ds/react';

const colors = ['neutral', 'brand', 'information', 'success', 'warning', 'error'] as const;

export default function Demo() {
  return (
    <div className="demo-stack">
      {(['soft', 'solid', 'outline'] as const).map((variant) => (
        <div key={variant} className="demo-row">
          {colors.map((c) => (
            <Badge key={c} color={c} variant={variant}>{c[0]!.toUpperCase() + c.slice(1)}</Badge>
          ))}
        </div>
      ))}
    </div>
  );
}

Sizes

Extra small 16, small 20, medium 24 and large 28. Extra small is for counts on icons.

import { Badge } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-row">
      <Badge size="xs" color="brand">Extra small</Badge>
      <Badge size="sm" color="brand">Small</Badge>
      <Badge size="md" color="brand">Medium</Badge>
      <Badge size="lg" color="brand">Large</Badge>
    </div>
  );
}

Dot and icon

A dot for statuses, or an icon for labels like Pro.

import { Badge } from '@halo-ds/react';
import { CheckCircle, Lightning } from '@phosphor-icons/react';

export default function Demo() {
  return (
    <div className="demo-row">
      <Badge color="success" dot>Active</Badge>
      <Badge color="warning" dot>Pending</Badge>
      <Badge color="error" dot>Failed</Badge>
      <Badge color="brand" variant="outline" icon={<Lightning />}>Pro</Badge>
      <Badge color="success" variant="outline" icon={<CheckCircle />}>Verified</Badge>
    </div>
  );
}

Counts

Single digits are circles. Bigger numbers grow into a pill and stop at max.

import { Badge } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-row">
      <Badge size="xs" color="error" variant="solid" count={3} aria-label="3 unread" />
      <Badge color="error" variant="solid" count={12} aria-label="12 unread" />
      <Badge size="lg" color="error" variant="solid" count={150} aria-label="150 unread" />
      <Badge count={1200} max={999} />
    </div>
  );
}

More: https://halodesignsystem.dev/components/badge