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
export const Default: Story = {};Outline
export const Outline: Story = {
args: {
appearance: 'outline',
},
};Overflow
export const Overflow: Story = {
args: {
count: 150,
overflowCount: 99,
},
};Zero Count
export const ZeroCount: Story = {
args: {
count: 0,
},
};Show Zero
export const ShowZero: Story = {
args: {
count: 0,
showZero: true,
},
};Dot
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
export const Colors: Story = {
render: renderColorRows,
};Dot Colors
export const DotColors: Story = {
args: {
dot: true,
},
render: renderColorRows,
};Shapes And Sizes
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
count | number | No | 0 | Number to show. Nothing renders for 0 (unless |
overflowCount | number | No | 99 | Maximum count before displaying overflow indicator (e.g. "99+"). |
appearance | 'filled' | 'outline' | 'ghost' | No | 'filled' | Visual style of the counter badge: |
shape | 'circular' | 'square' | 'rounded' | No | 'circular' | Corners: |
size | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | No | 'medium' | Size of the counter: 14px tall for |
color | 'brand' | 'success' | 'warning' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle' | No | 'brand' | Semantic color, from Badge's palette: |
dot | boolean | No | false | A 6px dot without a number (an "unread" indicator); |
showZero | boolean | No | false | Shows "0" for a count of 0; negative counts still render nothing. |
ref | React.Ref<HTMLSpanElement> | No | Ref to the root |
Any other prop is passed to the element it renders (HTMLSpanElement).
Stable class names
| Part | Class |
|---|---|
root | wave-counter-badge |