Skip to content

CounterBadge

CounterBadge

A small pill showing a count (unread messages, notifications), or with dot a small dot without a number. Renders nothing for a count of 0 (unless showZero) or less, and overflowCount+ above overflowCount. color takes Badge's palette, so a color means the same in both. The root carries data-color and data-appearance with the resolved values, and data-dot when it is a dot.

A count or dot whose meaning is not in the surrounding text 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

5
export const Default: Story = {};

Outline

5
export const Outline: Story = {
  args: {
    appearance: 'outline',
  },
};

Overflow

99+
export const Overflow: Story = {
  args: {
    count: 150,
    overflowCount: 99,
  },
};

Zero Count

export const ZeroCount: Story = {
  args: {
    count: 0,
  },
};

Show Zero

0
export const ShowZero: Story = {
  args: {
    count: 0,
    showZero: true,
  },
};

Dot

Inbox
export const Dot: Story = {
  args: {
    dot: true,
    'aria-label': 'Unread messages',
  },
  render: (args) => (
    <span className="inline-flex items-center gap-2 text-wave-body-1 text-wave-foreground">
      Inbox
      <CounterBadge {...args} />
    </span>
  ),
};

Colors

5brand5success5warning5danger5important5informative5severe5subtle
5brand5success5warning5danger5important5informative5severe5subtle
5brand5success5warning5danger5important5informative5severe5subtle
export const Colors: Story = {
  render: renderColorRows,
};

Dot Colors

brandsuccesswarningdangerimportantinformativeseveresubtle
brandsuccesswarningdangerimportantinformativeseveresubtle
brandsuccesswarningdangerimportantinformativeseveresubtle
export const DotColors: Story = {
  args: {
    dot: true,
  },
  render: renderColorRows,
};

Shapes And Sizes

555
55555
export const ShapesAndSizes: Story = {
  argTypes: { shape: { control: false }, size: { control: false } },
  render: (args) => (
    <div className="flex flex-col gap-3">
      <div className="flex items-center gap-3">
        {SHAPES.map((shape) => (
          <CounterBadge key={shape} {...args} shape={shape} />
        ))}
      </div>
      <div className="flex items-center gap-3">
        {SIZES.map((size) => (
          <CounterBadge key={size} {...args} size={size} />
        ))}
      </div>
    </div>
  ),
};

Props

NameTypeRequiredDefaultDescription
countnumberNo0

Number to show. Nothing renders for 0 (unless showZero) or less; above overflowCount the badge shows overflowCount+.

overflowCountnumberNo99

Maximum count before displaying overflow indicator (e.g. "99+").

appearance'filled' | 'outline' | 'ghost'No'filled'

Visual style of the counter badge: 'filled' a solid fill, 'outline' a border, 'ghost' the color as text alone, with no fill and no border. A dot has no text, so 'ghost' draws it as 'filled'. Fluent's appearance.

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

Corners: 'circular' a pill, 'rounded' softly rounded corners, 'square' none; a dot follows it too. Fluent's shape.

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

Size of the counter: 14px tall for 'extra-small', 16px 'small', 20px 'medium', 24px 'large' and 32px 'extra-large'. A dot is always 6px and ignores it. Fluent's size.

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

Semantic color, from Badge's palette: brand, danger, important, informative, severe, subtle, success, warning. important follows Badge (see BadgeProps.color): Fluent's neutral high-emphasis color, near black in the light theme and inverted in the dark one (severe is the orange it drew through 0.x). A value outside the palette (from untyped code) renders as brand.

dotbooleanNofalse

A 6px dot without a number (an "unread" indicator); count, overflowCount and showZero are ignored. Name it with aria-label when nothing else conveys its meaning. Its color keeps 3:1 against the page background in every theme, so informative (gray) and warning (dark yellow in the light theme) dots are darker than those counts; subtle is the page color, for dots on colored surfaces.

showZerobooleanNofalse

Shows "0" for a count of 0; negative counts still render nothing.

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-counter-badge