Badge

A small label for status, counts, or categorization.

Import

import { Badge } from '@matix/components/badge';

Usage

Badge

Variants

SolidOutlineSoft

Sizes

SmallMediumLarge

Icons

Pass an icon for an icon + text badge, or omit children for an icon-only badge. Icon-only badges should include an aria-label so they remain accessible.

VerifiedFeatured

Status

Use success, warning, destructive, and info for status. Each one is a tint of its semantic colour, with the text in the full colour.

ActivePendingFailedDraft

HTML Attributes

Badge forwards the normal <span> attributes, such as id, title, aria-hidden, and data-*.

<Badge variant="destructive" size="sm" aria-hidden="true" data-testid="unread">
  3
</Badge>

For a count on an icon button, use the IconButton count prop.

Custom Styles

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  pill: { borderRadius: '9999px' },
});

<Badge sx={custom.pill} variant="solid">
  Pill
</Badge>;

API Reference

PropTypeDefaultDescription
variant'solid' | 'outline' | 'soft' | 'success' | 'warning' | 'info' | 'destructive''soft'Visual style
size'sm' | 'md' | 'lg''md'Size preset
iconReactNode—Leading icon; omit children for icon-only
sxStyleXStyles—StyleX style override
childrenReactNode—Badge content

All other HTML attributes are forwarded to the <span>.

Accessibility

  • Renders a <span> element with no implicit ARIA role.
  • If the badge communicates status or count information that is not otherwise available to screen readers, add aria-label to the containing element or use a visually-hidden description.
  • Do not use Badge as a standalone interactive element — it has no keyboard or click behavior.

This is an RSC-safe component — it ships no JavaScript to the browser.