Badge
Badges are used to highlight status, categories, or small pieces of information.
Installation
Add the badge component to your project:
Usage
Default Badge
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Variants
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Sizes
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Pill Shape
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
With Icon
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Removable
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Custom Labels
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Badge
Live preview rendered from the registry in an isolated iframe.
Loading preview...
Failed to load preview
Badge
Full preview from the registry iframe.
Loading preview...
Props
| Prop | Type | Default | Description |
|---|---|---|---|
variant |
string |
'default' |
Visual style: default, primary, secondary, destructive, outline |
size |
string |
'default' |
Size: sm, default, lg |
pill |
boolean |
false |
Use pill/rounded shape instead of default squared corners |
icon |
string |
null |
Icon name to display before the text |
removable |
boolean |
false |
Show remove button (×) to dismiss the badge |
label |
string |
'Badge' |
Text content to display |
Examples
Status Indicators
<div class="flex items-center gap-2">
<span>Account Status:</span>
<x-ui.badge variant="success">Active</x-ui.badge>
</div>
<div class="flex items-center gap-2">
<span>Payment Status:</span>
<x-ui.badge variant="destructive">Overdue</x-ui.badge>
</div>
<div class="flex items-center gap-2">
<span>Verification:</span>
<x-ui.badge variant="primary" icon="check">Verified</x-ui.badge>
</div>
Filter Tags
<div class="flex items-center gap-2">
<x-ui.badge variant="secondary" removable>Category</x-ui.badge>
<x-ui.badge variant="secondary" removable>Price Range</x-ui.badge>
<x-ui.badge variant="secondary" removable>Brand</x-ui.badge>
</div>
Product Tags
<div class="flex items-center gap-2">
<x-ui.badge variant="primary" pill>New</x-ui.badge>
<x-ui.badge variant="success" pill>In Stock</x-ui.badge>
<x-ui.badge variant="outline" pill>On Sale</x-ui.badge>
</div>
Notification Badges
<div class="relative">
<button>
Notifications
</button>
<x-ui.badge variant="destructive" class="absolute -top-2 -right-2">3</x-ui.badge>
</div>
Counters
<div class="flex items-center gap-4">
<div>
<p class="text-sm text-muted-foreground">Tasks</p>
<x-ui.badge size="lg" variant="primary">12</x-ui.badge>
</div>
<div>
<p class="text-sm text-muted-foreground">Messages</p>
<x-ui.badge size="lg" variant="secondary">5</x-ui.badge>
</div>
<div>
<p class="text-sm text-muted-foreground">Alerts</p>
<x-ui.badge size="lg" variant="destructive">2</x-ui.badge>
</div>
</div>
Accessibility
Badge components include proper ARIA attributes:
- Semantic HTML structure
- Clear visual contrast ratios
- Proper text scaling for different sizes
- Accessible color combinations
Customization
The badge component uses Tailwind CSS classes. You can customize the appearance by modifying the component in your project:
@
@props([
'variant' => 'default',
'size' => 'md',
'pill' => false,
'icon' => null,
'removable' => false,
])
// Customize variants, sizes, and styles
Variant Styles
| Variant | Use Case |
|---|---|
default |
General purpose labels |
primary |
Important highlights |
secondary |
Subtle information |
destructive |
Errors or destructive actions |
outline |
Bordered badges |
Icon Integration
The badge component integrates with your icon system. Any icon name available in your project can be used:
<x-ui.badge icon="star">Featured</x-ui.badge>
<x-ui.badge icon="heart">Liked</x-ui.badge>
<x-ui.badge icon="bookmark">Saved</x-ui.>
## Next Steps
- Explore [Alert component](/docs/components/alert)
- Learn about [Button component](/docs/components/button)
- View [Breadcrumbs component](/docs/components/breadcrumbs)