Badge

A short label in a pill: a status, a stage, or a tag a lawyer can remove. `tone` picks the colour from the status palette and `variant` the treatment, soft or outline. An icon can sit before the text, and a remove × or an icon after it. CountBadge is the quiet count beside a tab or heading.

BetaReady to use. Its API can still change in a minor release; the changelog says when.

import { Badge, BadgeGroup, BadgePresence, CountBadge } from "@leap-crm/design-system";

Playground

Change a prop and the component follows. Its code is under Props.

Badge

Approved

Props

children
variant
size
tone
icon
endIcon
onRemove

CountBadge

3

Props

size
value

Best practices

When to use it, and the rules that apply in particular places.

GuidancePractice
DoWrite the status in the badge, like Overdue or Converted. The tone adds emphasis, but colour is never the only signal.
DoPick the colour with tone and the treatment with variant: soft for most badges, outline where a tinted fill would crowd a dense row.
DoUse size="sm" in dense rows like a table cell, and xs only for small labels like Beta.
DoUse CountBadge for the number of items beside a tab or section heading, and pass "99+" past 99 so the pill stays short.
DoWrap badges that come and go in BadgeGroup, or a single one in BadgePresence, so a removed badge fades and the row closes up instead of jumping.
Don'tPut a clickable icon in endIcon. It is decorative; for a label a lawyer can take off, pass onRemove, which gives the × a name and a 24 px target.
Don'tTint a whole row or card in a badge's tone. Colour is an accent: keep it in the badge and leave the surface neutral.

Props

Badge also takes every attribute of a span.

Badge

PropTypeDefaultDescription
childrenReactNode—What it shows inside.
toneTone"default"The colour, from the status palette. Pair it with words: the colour is never the only signal.
variant"soft" | "outline""soft"soft (the default) is the tone's tinted fill and border; outline keeps the tone's border and text on no fill.
size"md" | "sm" | "xs""md"md (22 px) by default; sm (18 px) in dense rows; xs (15 px) for labels like Beta.
iconReactNode—An icon before the text, like a tick on Approved.
endIconReactNode—A decorative icon after the text. With onRemove, the × takes this place.
onRemove() => void—Shows a remove × after the text, like a tag a lawyer added. Called when it's pressed.
removeLabelstring—The remove button's name. "Remove <text>" by default.

CountBadge

PropTypeDefaultDescription
value *number | string—The count. Past 99, pass "99+".
size"md" | "sm""md"md (16 px) beside tabs and buttons; sm (14 px) beside inline section heads.
classNamestring—Classes added to the root element, merged with its own. Tokens only.

BadgePresence

PropTypeDefaultDescription
show *boolean—Whether the badge shows. Turning it off plays the badge out before it unmounts.
gapRowGap8The flex gap, in px, between the badge and what sits before it, so that gap opens and closes with it. Leave it out for a floating badge.
floatingstring—A badge pinned over something, like a count on an icon, takes no space in the row: it turns in and out where it sits. Pass its position classes here, like "absolute -end-0.5 -top-0.5".
children *ReactNode—The badge, usually a Badge or CountBadge.

BadgeGroup

PropTypeDefaultDescription
children *ReactNode—The badges, each with a key, like a contact's tags. One added or removed opens or closes its own space.
gapRowGap8The gap between badges, in px: 4, 6 or 8 (the default).
classNamestring—Classes added to the root element, merged with its own. Tokens only.

Code

What the playground shows, ready to copy.

Badge

import { Badge } from "@leap-crm/design-system";

<Badge tone="success">Approved</Badge>

CountBadge

import { CountBadge } from "@leap-crm/design-system";

<CountBadge value={3} />

Removable

onRemove puts a × after the text. Its target reaches 24 px without growing the badge, and it is named Remove <text>. In a BadgeGroup the row closes up behind a removed badge.

UrgentFamily lawReferralVIP

Coming and going

BadgePresence shows one badge when there's something to show, like a count above zero: its space opens and it turns in, and leaving it fades before the row closes up, so the words beside it slide rather than jump. BadgeGroup does the same for a row of keyed badges, like a record's tags. Pass floating for a badge pinned over an icon, which turns in where it sits. Reduced motion fades.

Tasksdue today
VIP

What the examples share

The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.

import { Fragment, useState } from "react";

import { Badge, BadgeGroup, BadgePresence, Button, CheckIcon, ClockIcon, CountBadge } from "@leap-crm/design-system";

const tagPool = [
  { id: "vip", label: "VIP", tone: "purple" },
  { id: "referral", label: "Referral", tone: "teal" },
  { id: "overdue", label: "Overdue", tone: "warning" },
  { id: "on-hold", label: "On hold", tone: "yellow" },
] as const;

const matterTags = [
  { name: "Urgent", tone: "destructive" },
  { name: "Family law", tone: "purple" },
  { name: "Referral", tone: "teal" },
  { name: "VIP", tone: "yellow" },
] as const;

function RemovableTags() {
  const [names, setNames] = useState<string[]>(matterTags.map(tag => tag.name));
  return (
    <div className="flex flex-col items-start gap-3">
      <BadgeGroup className="min-h-5.5">
        {matterTags
          .filter(tag => names.includes(tag.name))
          .map(tag => (
            <Badge
              key={tag.name}
              tone={tag.tone}
              onRemove={() =>
                setNames(current => current.filter(name => name !== tag.name))
              }
            >
              {tag.name}
            </Badge>
          ))}
      </BadgeGroup>
      <Button
        intent="ghost"
        size="xs"
        onClick={() => setNames(matterTags.map(tag => tag.name))}
      >
        Put them back
      </Button>
    </div>
  );
}

function ComingAndGoing() {
  const [count, setCount] = useState(0);
  const [tags, setTags] = useState<string[]>(["vip"]);
  const toggle = (id: string) =>
    setTags(current =>
      current.includes(id)
        ? current.filter(tag => tag !== id)
        : tagPool
            .map(tag => tag.id)
            .filter(tag => tag === id || current.includes(tag)),
    );
  return (
    <div className="flex flex-col gap-5">
      <div className="flex items-center gap-4">
        <span className="text-body text-neutral-text flex items-center gap-2">
          Tasks
          <BadgePresence show={count > 0}>
            <CountBadge value={count} />
          </BadgePresence>
          <span className="text-neutral-text-muted">due today</span>
        </span>
        <Button
          intent="outline"
          size="sm"
          onClick={() => setCount(value => value + 1)}
        >
          Add task
        </Button>
        <Button intent="ghost" size="sm" onClick={() => setCount(0)}>
          Clear
        </Button>
      </div>
      <div className="flex flex-col gap-2">
        <BadgeGroup className="min-h-5.5">
          {tagPool
            .filter(tag => tags.includes(tag.id))
            .map(tag => (
              <Badge key={tag.id} tone={tag.tone}>
                {tag.label}
              </Badge>
            ))}
        </BadgeGroup>
        <div className="flex flex-wrap gap-2">
          {tagPool.map(tag => (
            <Button
              key={tag.id}
              intent="ghost"
              size="xs"
              aria-pressed={tags.includes(tag.id)}
              onClick={() => toggle(tag.id)}
            >
              {tag.label}
            </Button>
          ))}
        </div>
      </div>
    </div>
  );
}

const tones = [
  "default",
  "info",
  "success",
  "warning",
  "destructive",
  "teal",
  "purple",
  "yellow",
  "slate",
  "plum",
] as const;

const labels: Record<(typeof tones)[number], string> = {
  default: "Lead",
  info: "Enquired",
  success: "Converted",
  warning: "Overdue",
  destructive: "Lost",
  teal: "Agreement",
  purple: "Referral",
  yellow: "On hold",
  slate: "Archived",
  plum: "Disqualified",
};