Badge
Badge is a small visual label used to highlight status, count, or category. It
is a standalone component (no upstream Spar primitive) that follows Takeoff
visual vocabulary.
Usage
import { Badge } from '@takeoff-ui/react-spar';
<Badge variant="success">Active</Badge>
Playground
Variants
Appearances
Sizes
Rounded
Icons
Dot
Float
API Reference
Badge
Props
| Name | Type | Default | Description |
|---|---|---|---|
| children | React.ReactNode | - | Badge content. |
| variant | BadgeVariant | 'primary' | Color variant. |
| appearance | BadgeAppearance | 'filled' | Visual appearance. |
| size | BadgeSize | 'base' | Size scale. |
| rounded | boolean | false | Renders a pill-shaped badge with fully rounded corners. |
| dot | boolean | false | Renders a minimal colored dot (8×8px) with no content. When true, children, startContent, and endContent are ignored. |
| startContent | React.ReactNode | - | Content rendered before children — typically an icon. |
| endContent | React.ReactNode | - | Content rendered after children. |
| classNames | Partial<Record<BadgeSlot, string>> | - | Per-slot extra classes. |
| slotProps | Partial<Record<BadgeSlot, React.HTMLAttributes<HTMLElement>>> | - | Per-slot HTML-attribute overrides. |
| className | string | - | Appends custom classes to the root slot. |
Data attributes
| Attribute | Applied when | Purpose |
|---|---|---|
| data-slot="root" | Always | Stable selector for wrapper styling on the root slot. |
| data-variant | Always | Reflects the resolved variant prop for theme recipe scoping. |
| data-type | Always | Reflects the resolved appearance prop for theme recipe scoping. |
| data-size | When dot is false | Reflects the resolved size prop for theme recipe scoping. |
| data-rounded | When rounded is true | Styling hook for the pill-shaped state. |
| data-dot | When dot is true | Styling hook for the minimal dot mode. |
Type Definitions
| Name | Definition |
|---|---|
| BadgeVariant | | 'primary' | 'secondary' | 'neutral' | 'info' | 'success' | 'danger' | 'warning' | 'verified' | 'purple' | 'cyan' | 'business' | 'teal' | 'white' | 'dark' |
| BadgeAppearance | 'filled' | 'filledLight' | 'outlined' | 'text' |
| BadgeSize | 'small' | 'base' | 'large' |
| BadgeSlot | 'root' | 'label' | 'icon' |