Badge
A compact presentational label for displaying status, category, count, or other short contextual information.
Import Badge
Import Badge from Tavix:
import { Badge } from "tavix";Component API
<Badge
variant="neutral"
size="md"
appearance="soft"
icon
className=""
{...props}
>
Status
</Badge>variant: Color treatment:neutral,brand,success,warning,error, orinfo. Defaults toneutral.size: Badge size:smormd. Defaults tomd.appearance: Visual appearance:softorsolid. Defaults tosoft.icon: Registered Tavix icon name displayed before the content.children: Content displayed inside the badge.className: Additional classes applied to the badge....props: Additional props forwarded to the root<span>.
Behavior
- Renders a compact, presentational label.
- Applies the selected
variantcolor treatment. - Supports
softandsolidappearances. - Supports
smandmdsizes. - Renders an icon before the content when
iconis provided. - Marks icons as decorative and hides them from assistive technology.
- Forwards additional props to the root
<span>. - Does not provide click, focus, or selection behavior.
Examples
Status badges
<Badge variant="success" appearance="solid" icon="check-circle">
Active
</Badge>
<Badge variant="warning" size="sm">
Pending
</Badge>Badge variants
<Badge variant="neutral">Draft</Badge>
<Badge variant="brand">Featured</Badge>
<Badge variant="success">Active</Badge>
<Badge variant="warning">Pending</Badge>
<Badge variant="error">Failed</Badge>
<Badge variant="info">Info</Badge>Soft and solid appearances
<Badge variant="brand" appearance="soft">
Soft badge
</Badge>
<Badge variant="brand" appearance="solid">
Solid badge
</Badge>Sizes
<Badge size="sm">Small</Badge>
<Badge size="md">Medium</Badge>Count badge
<Badge variant="error" aria-label="3 unread notifications">
3
</Badge>Accessibility
- Badge content should be concise and understandable in its surrounding context.
- Do not rely on color alone to communicate status.
- Icons are decorative and hidden from assistive technology.
- Use
aria-labelwhen a short or visual badge needs additional context. - Badge is non-interactive; use a Button or link when users need to take action.
Notes
- Badge renders a
<span>element. - Supported variants are
neutral,brand,success,warning,error, andinfo. - Supported sizes are
smandmd. - Supported appearances are
softandsolid. - The component does not manage state or user interaction.
- Additional props are forwarded to the root element.