# Badge

A short label beside content: a record's status in a pill (subtle or bold), a live state as a dot and a word, or a count.

- Family: display
- Import: `import { Badge, BadgeAnchor } from "@senvenli/react/display";`
- Page: https://design.senvenli.com/docs/components/badge
- JSON: https://design.senvenli.com/docs/components/badge.json

## Example: A record's status

`subtle` (the default): one or two words in sentence case; the word carries the meaning, never the color alone.

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-100">
      <Text weight="medium">Invoice INV-2026-0318</Text>
      <Badge tone="success">Paid</Badge>
    </Stack>
  );
}
```

## Examples

### Tones

One meaning per tone, across the whole product.

```tsx
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-100">
      <Badge>Draft</Badge>
      <Badge tone="information">In progress</Badge>
      <Badge tone="brand">Featured</Badge>
      <Badge tone="success">Completed</Badge>
      <Badge tone="warning">Payment pending</Badge>
      <Badge tone="danger">Canceled</Badge>
    </Stack>
  );
}
```

### Bold

`variant="bold"` for the one status on the screen that needs attention now.

```tsx
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-100">
      <Badge tone="danger" variant="bold">
        Overdue
      </Badge>
      <Badge tone="warning">Payment pending</Badge>
      <Badge tone="success">Paid</Badge>
    </Stack>
  );
}
```

### With a dot

A dot in the pill marks a live state.

```tsx
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-100">
      <Badge tone="success" hasDot>
        Online
      </Badge>
      <Badge tone="information" hasDot>
        Syncing
      </Badge>
    </Stack>
  );
}
```

### Dot: a live state

`variant="dot"`: a dot and a word, for a system state (connected, syncing).

```tsx
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-300">
      <Badge variant="dot" tone="success">Connected</Badge>
      <Badge variant="dot" tone="information">Syncing</Badge>
      <Badge variant="dot" tone="warning">Slow connection</Badge>
      <Badge variant="dot" tone="danger">Offline</Badge>
      <Badge variant="dot">Not set up</Badge>
    </Stack>
  );
}
```

### Dot and live

`isLive` adds a halo for a state that is active right now.

```tsx
import { Text } from "@senvenli/react/display";
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-200" justify="between">
      <Text weight="medium">Payments webhook</Text>
      <Badge variant="dot" tone="success" isLive>Receiving events</Badge>
    </Stack>
  );
}
```

### Dot without a word

Only where a visible word is impossible; `aria-label` names the state.

```tsx
import { Text } from "@senvenli/react/display";
import { Badge } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

const INTEGRATIONS = [
  { name: "Accounting", tone: "success", state: "Connected" },
  { name: "Email", tone: "warning", state: "Slow connection" },
  { name: "Calendar", tone: "danger", state: "Offline" },
] as const;

export default function Example() {
  return (
    <Stack space="space-100">
      {INTEGRATIONS.map((integration) => (
        <Stack direction="horizontal" key={integration.name} space="space-100">
          <Badge variant="dot" tone={integration.tone} aria-label={integration.state} />
          <Text>{integration.name}</Text>
        </Stack>
      ))}
    </Stack>
  );
}
```

### A count beside a label

`variant="count"`: nothing renders at zero; above `max` it reads "99+".

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-300">
      <Stack direction="horizontal" space="space-075">
        <Text>Open orders</Text>
        <Badge variant="count" value={12} />
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Text>Messages</Text>
        <Badge variant="count" value={128} />
      </Stack>
    </Stack>
  );
}
```

### Count tones

Neutral by default; danger only for counts that need action now.

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-300">
      <Stack direction="horizontal" space="space-075">
        <Text>Drafts</Text>
        <Badge variant="count" value={4} />
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Text>New customers</Text>
        <Badge variant="count" value={7} tone="brand" />
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Text>Overdue invoices</Text>
        <Badge variant="count" value={2} tone="danger" />
      </Stack>
      <Stack direction="horizontal" space="space-075">
        <Text>Archived</Text>
        <Badge variant="count" value={31} tone="inverse" />
      </Stack>
    </Stack>
  );
}
```

### A count on an icon

The badge is hidden from screen readers, so the button's name carries the count.

```tsx
import { Button } from "@senvenli/react/action";
import { Badge, BadgeAnchor } from "@senvenli/react/display";

export default function Example() {
  return (
    <BadgeAnchor>
      {/* On an icon the cap is 9, and the label says what the badge shows. */}
      <Button iconOnly iconBefore="bell" aria-label="Notifications, 9+ unread" />
      <Badge variant="count" value={12} tone="brand" />
    </BadgeAnchor>
  );
}
```

### Unread dot

`variant="count"` with no `value`: a marker without a number; the text beside it says what is new.

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-075">
      <Badge variant="count" />
      <Text>New comments on Project Atlas</Text>
    </Stack>
  );
}
```

### A code: Beside a country's name

The code marks the country without a flag; the name beside it is what gets read.

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

const COUNTRIES = [
  { code: "DE", name: "Germany" },
  { code: "US", name: "United States" },
  { code: "JP", name: "Japan" },
];

export default function Example() {
  return (
    <Stack space="space-100">
      {COUNTRIES.map((country) => (
        <Stack direction="horizontal" key={country.code} space="space-100">
          <Badge>{country.code}</Badge>
          <Text>{country.name}</Text>
        </Stack>
      ))}
    </Stack>
  );
}
```

### A code: Standing alone

Without the name beside it, a wrapper gives the chip its accessible name.

```tsx
import { Badge, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";

export default function Example() {
  return (
    <Stack direction="horizontal" space="space-100">
      <Text>Ships from</Text>
      <span role="img" aria-label="Germany">
        <Badge>DE</Badge>
      </span>
    </Stack>
  );
}
```

## Guidelines

### When to use it

- Showing the state of an item: draft, paid, overdue.
- Showing how many items need attention.
- Marking a country or language next to its name.

### Use something else when

- [tag-group](https://design.senvenli.com/docs/components/tag-group.md): The labels can be removed or selected.
- [avatar](https://design.senvenli.com/docs/components/avatar.md): The label is a person or a company.

### Do and avoid

- The word carries the meaning, never the color alone; use sentence case.
- Use the bold appearance sparingly, for the one status that matters most.
- Use `danger` only for counts that need action now.

## Accessibility

Built in:

- Text meets WCAG AA in both appearances.
- Counts above `max` show as "max+".
- On an icon the badge is hidden; the control's label must say the count.
- Hidden from screen readers when the name is next to it.

You provide:

- A status word that makes sense without color.
- The count in the control's accessible name when the badge sits on an icon.
- The name beside it.

## API reference

### Badge

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| tone | `Tone \| BadgeCountTone` |  | no | One meaning per tone: information (Approved, In progress) · brand (Featured) · success (Completed, Available, Paid) · warning (Payment pending, Under review) · danger (Canceled, Failed, Overdue) · neutral (Draft, Inactive). |
| variant | `"bold" \| "dot" \| "subtle" \| "count"` |  | no | `subtle` (default): the status of a record in a pill. `bold`: the one status on the screen that needs attention now. `dot`: a dot and the word, for a live system state (online, syncing). |
| hasDot | `boolean` |  | no | A 6px dot inside a pill (subtle or bold), for live states. `dot` always has its dot. |
| radius | `ComponentRadius` |  | no | Pills only (`subtle`, `bold`): corner radius, `none` to `full`; the design's small step (or the provider's default) otherwise. |
| isLive | `boolean` |  | no | `dot` only: a 3px halo for a state that is active right now (connected, syncing). |
| children | `React.ReactNode` |  | no | The status word, sentence case ("Payment pending"); the word carries the meaning, never the colour. |
| aria-label | `string` |  | no | `dot` only, where a visible word is impossible (a dense table cell with its own column header). |
| value | `number` |  | no | The count; nothing renders at 0. Left out, an 8px unread marker without a number, hidden from screen readers, so the text or label next to it says "new". |
| max | `number` |  | no | Above it shows "max+"; default 99, or 9 on an icon. |

### BadgeAnchor

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| children | `React.ReactNode` |  | yes |  |

### Tokens it reads

`--ds-background-brand-bold`, `--ds-background-brand-subtle`, `--ds-background-danger`, `--ds-background-danger-bold`, `--ds-background-information`, `--ds-background-information-bold`, `--ds-background-neutral`, `--ds-background-neutral-bold`, `--ds-background-success`, `--ds-background-success-bold`, `--ds-background-warning`, `--ds-background-warning-bold`, `--ds-easing-enter`, `--ds-icon-brand`, `--ds-icon-danger`, `--ds-icon-information`, `--ds-icon-subtle`, `--ds-icon-success`, `--ds-icon-warning`, `--ds-radius-control-small`, `--ds-radius-full`, `--ds-space-050`, `--ds-space-075`, `--ds-space-100`, `--ds-surface`, `--ds-text`, `--ds-text-brand`, `--ds-text-danger`, `--ds-text-information`, `--ds-text-inverse`, `--ds-text-on-bold`, `--ds-text-on-brand`, `--ds-text-on-danger`, `--ds-text-on-warning`, `--ds-text-subtle`, `--ds-text-success`, `--ds-text-warning`

## Related

- [icon](https://design.senvenli.com/docs/components/icon.md)
- [input](https://design.senvenli.com/docs/components/input.md)
