Kobalte.v0.13.7

Badge

A Badge component is used to display small pieces of information or status indicators.

Import

ts
import { Badge } from "@kobalte/core/badge";
// or
import { Root } from "@kobalte/core/badge";
ts
import { Badge } from "@kobalte/core/badge";
// or
import { Root } from "@kobalte/core/badge";

Features

  • Auto-populated ARIA labeling via the textValue prop for enhanced accessibility.
  • Built-in ARIA support with role="status" to communicate dynamic updates.

Anatomy

The badge consists of:

  • Badge: The root container for the badge that supports accessibility and content customization.
tsx
<Badge textValue="3 online users">3</Badge>
tsx
<Badge textValue="3 online users">3</Badge>

Example

5 messages

API Reference

Badge

Badge is equivalent to the Root import from @kobalte/core/badge.

PropDescription
textValuestring | undefined
The textValue prop is essential for accessibility. It auto-populates the aria-label attribute, allowing screen readers to interpret the badge’s content.
Data attributeDescription
data-labelPresent when textValue is passed or aria-label is passed as a prop.

Rendered elements

ComponentDefault rendered element
Badgespan