Skip to content

Badge

Badge

A short, non-interactive label that highlights a status or category ("New", "Beta", "3"). appearance picks a solid fill, a light tint, an outline or the color as text alone; color the semantic color; shape the corners; icon adds a glyph. Colors come from the theme tokens, so the text keeps its contrast in the light, dark and high-contrast themes. The root carries data-color, data-appearance, data-shape and data-size with the resolved values.

A badge whose text alone does not say what it means ("3") can be named with aria-label or aria-labelledby: it then gets role="img" (unless you pass a role), so the name is announced. An empty or whitespace-only name counts as absent and adds no role.

Examples

Default

Badge
export const Default: Story = {};

Appearances

filledtintoutlineghost
export const Appearances: Story = {
  render: (args) => (
    <div className="flex gap-2">
      {APPEARANCES.map((appearance) => (
        <Badge key={appearance} {...args} appearance={appearance}>
          {appearance}
        </Badge>
      ))}
    </div>
  ),
};

Colors

brandsuccesswarningdangerimportantinformativeseveresubtle
brandsuccesswarningdangerimportantinformativeseveresubtle
brandsuccesswarningdangerimportantinformativeseveresubtle
brandsuccesswarningdangerimportantinformativeseveresubtle
export const Colors: Story = {
  render: (args) => (
    <div className="flex flex-col gap-2">
      {APPEARANCES.map((appearance) => (
        <div key={appearance} className="flex gap-2">
          {COLORS.map((color) => (
            <Badge key={color} {...args} appearance={appearance} color={color}>
              {color}
            </Badge>
          ))}
        </div>
      ))}
    </div>
  ),
};

Important And Severe

importantsevere
importantsevere
importantsevere
importantsevere
export const ImportantAndSevere: Story = {
  render: (args) => (
    <div className="flex flex-col gap-2">
      {APPEARANCES.map((appearance) => (
        <div key={appearance} className="flex gap-2">
          <Badge {...args} appearance={appearance} color="important">
            important
          </Badge>
          <Badge {...args} appearance={appearance} color="severe">
            severe
          </Badge>
        </div>
      ))}
    </div>
  ),
};

Sizes

extra-smallsmallmediumlargeextra-large
export const Sizes: Story = {
  render: (args) => (
    <div className="flex items-center gap-2">
      {SIZES.map((size) => (
        <Badge key={size} {...args} size={size}>
          {size}
        </Badge>
      ))}
    </div>
  ),
};

Shapes

circularroundedsquare
export const Shapes: Story = {
  argTypes: { shape: { control: false } },
  render: (args) => (
    <div className="flex items-center gap-2">
      {SHAPES.map((shape) => (
        <Badge key={shape} {...args} shape={shape}>
          {shape}
        </Badge>
      ))}
    </div>
  ),
};

With Icon

BeforeAfter
export const WithIcon: Story = {
  args: {
    icon: (
      <svg viewBox="0 0 16 16" fill="currentColor" aria-hidden="true">
        <path d="M6.5 11.2 3.3 8l-1 1 4.2 4.2 7.2-7.2-1-1z" />
      </svg>
    ),
  },
  render: (args) => (
    <div className="flex items-center gap-2">
      <Badge {...args}>Before</Badge>
      <Badge {...args} iconPosition="after">
        After
      </Badge>
      <Badge {...args} aria-label="Verified" children={undefined} />
    </div>
  ),
};

Tiny

export const Tiny: Story = {
  args: { size: 'tiny', 'aria-label': 'Unread', children: undefined },
  render: (args) => (
    <div className="flex items-center gap-3">
      {APPEARANCES.map((appearance) => (
        <Badge key={appearance} {...args} appearance={appearance} aria-label={appearance} />
      ))}
    </div>
  ),
};

Props

NameTypeRequiredDefaultDescription
appearance'filled' | 'tint' | 'outline' | 'ghost'No'filled'

Visual style of the badge: 'filled' a solid fill, 'tint' a light tint, 'outline' a border, 'ghost' the color as text alone, with no fill and no border. Fluent's appearance.

color'brand' | 'success' | 'warning' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle'No'brand'

Semantic color: brand, danger, important, informative, severe, subtle, success, warning. important is Fluent's neutral high-emphasis color: near black with white text in the light theme, inverted in the dark one (through 0.x it was the orange that severe draws). severe is dark orange. subtle is the page background with foreground text, for colored surfaces.

shape'circular' | 'square' | 'rounded'No'circular'

Corners of the badge: 'circular' a pill, 'rounded' softly rounded corners, 'square' none. Fluent's shape.

size'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large'No'medium'

Size of the badge. 'tiny' is a 6px dot: it draws no content (children and icon are not rendered) and, for 'filled', 'tint' and 'ghost', the color's solid dot (a tint or a text color alone would not stand out at that size); 'outline' draws a ring. Name a tiny badge with aria-label when nothing else conveys its meaning.

iconSlot<'span'>No

An icon beside the text, decorative (aria-hidden), in a <span> with the stable class wave-badge__icon that fills it with a <svg>. A Slot<'span'>: a node, or an object of the element's props. Ignored for size="tiny". Fluent's icon.

iconPosition'before' | 'after'No'before'

Which side of the text the icon takes: 'before' the inline start, 'after' the inline end, so the sides follow the writing direction. Fluent's iconPosition.

refReact.Ref<HTMLSpanElement>No

Ref to the root <span>.

Any other prop is passed to the element it renders (HTMLSpanElement).

Stable class names

PartClass
rootwave-badge
iconwave-badge__icon