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
export const Default: Story = {};Appearances
export const Appearances: Story = {
render: (args) => (
<div className="flex gap-2">
{APPEARANCES.map((appearance) => (
<Badge key={appearance} {...args} appearance={appearance}>
{appearance}
</Badge>
))}
</div>
),
};Colors
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
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
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
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
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
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
appearance | 'filled' | 'tint' | 'outline' | 'ghost' | No | 'filled' | Visual style of the badge: |
color | 'brand' | 'success' | 'warning' | 'danger' | 'important' | 'informative' | 'severe' | 'subtle' | No | 'brand' | Semantic color: |
shape | 'circular' | 'square' | 'rounded' | No | 'circular' | Corners of the badge: |
size | 'tiny' | 'extra-small' | 'small' | 'medium' | 'large' | 'extra-large' | No | 'medium' | Size of the badge. |
icon | Slot<'span'> | No | An icon beside the text, decorative ( | |
iconPosition | 'before' | 'after' | No | 'before' | Which side of the text the icon takes: |
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-badge |
icon | wave-badge__icon |