Badge

Labels and status indicators for UI elements

Badge

Badges are used to highlight status, categories, or small pieces of information.

Installation

Add the badge component to your project:

npx velyx add badge
pnpm dlx velyx add badge
yarn dlx velyx add badge
bunx --bun velyx add badge

Usage

Default Badge

Loading preview...

Failed to load preview

Code

Variants

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Sizes

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Pill Shape

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

With Icon

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Removable

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Custom Labels

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

Loading preview...

Failed to load preview

Code

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:

```blade <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