elementsbadge
Badge
Compact label component with icon slots and variant styles.
Import#
Slot Structure#
Compact label with optional leading and trailing icon slots.
Examples#
Variants#
Default, outline, and solid styles.
Sizes#
Size scale with leading and trailing icons.
Status and Metadata#
Common badge content for pills, counters, and status labels.
Dismissible tags#
Clickable trailing icons support removable tag UIs like Select multi-value chips.
API Reference#
Attributes#
Slot
root2 attributesInline badge container that carries the variant, size, and interactive state.
Data Attributes
| Data Attribute | Description |
|---|---|
| data-size | Stores the resolved size variant. |
| data-variant | Stores the resolved visual variant. |
Props#
| Prop | Type | Default | Description |
|---|---|---|---|
| children | JSX.Element | — | Children of the badge. |
| class | ClassValue | — | Class applied to the component root or trigger element. |
| classes | BadgeT.Classes | undefined | — | — |
| leading | IconT.Name | — | Leading icon name. |
| onTrailingClick | JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent> | undefined | — | Callback when the trailing icon/button is clicked. |
| ref | JSX.HTMLElementTags["span"] extends { ref?: infer Ref; } ? Ref : never | undefined | — | — |
| size | "xs" | "sm" | "md" | "lg" | "xl" | undefined | — | — |
| style | JSX.CSSProperties | undefined | — | — |
| styles | BadgeT.Styles | undefined | — | — |
| title | string | undefined | — | Accessible title shown by the browser for the badge root. |
| trailing | IconT.Name | — | Trailing icon name. |
| variant | "default" | "outline" | "solid" | undefined | — | — |