Badge
Usage
Label
Use the label prop to set the text of the badge. The default slot replaces it.
<KBadge label="Pending" />
Variant
Use the variant prop to change the look of the badge: soft (default), solid or outline.
<KBadge label="Paid" color="success" />
<KBadge label="Paid" color="success" variant="solid" />
<KBadge label="Paid" color="success" variant="outline" />
Color
Use the color prop to change the color of the badge: gray (default), secondary, success, warning, danger, info or discovery.
<KBadge label="Pending" />
<KBadge label="Beta" color="secondary" />
<KBadge label="Paid" color="success" />
<KBadge label="Due soon" color="warning" />
<KBadge label="Overdue" color="danger" />
<KBadge label="New" color="info" />
<KBadge label="Beta" color="discovery" />
Size
Use the size prop to change the size of the badge: sm (default), md or lg.
<KBadge label="Paid" color="success" />
<KBadge label="Paid" color="success" size="md" />
<KBadge label="Paid" color="success" size="lg" />
Pill
Badges have rounded corners that follow the size by default. Set pill to make them fully round.
<KBadge label="Overdue" color="danger" variant="outline" size="md" />
<KBadge label="Overdue" color="danger" variant="outline" size="md" pill />
Dot
Set dot to show a small dot before the label, in the color of the text. It suits live statuses.
<KBadge label="Active" color="success" size="md" pill dot />
<KBadge label="Paused" size="md" pill dot />
<KBadge label="Failed" color="danger" size="md" pill dot />
Icon
Use the leading-icon and trailing-icon props to show an icon before or after the label. They take a Lucide icon component.
<script setup lang="ts">
import { BadgeCheck, Repeat, Sparkles, TrendingDown, TrendingUp } from 'lucide-vue-next'
</script>
<template>
<KBadge label="12.5%" color="success" size="md" pill :leading-icon="TrendingUp" />
<KBadge label="3.2%" color="danger" size="md" pill :leading-icon="TrendingDown" />
<KBadge label="Verified" color="info" size="md" :leading-icon="BadgeCheck" />
<KBadge label="Recurring" variant="outline" size="md" :leading-icon="Repeat" />
<KBadge label="Pro" color="discovery" variant="solid" size="md" :trailing-icon="Sparkles" />
</template>
Customization
Use the ui prop to change the classes of each part of the badge, and class for the root element. Your classes always win: rounded-none replaces the default rounded-sm instead of being added to it.
<KBadge label="Square corners" :ui="{ base: 'rounded-none' }" />
API
Props
| Prop | Type | Default |
|---|---|---|
label | string | |
variant | 'soft' | 'solid' | 'outline' | 'soft' |
color | 'gray' | 'secondary' | 'success' | 'warning' | 'danger' | 'info' | 'discovery' | 'gray' |
size | 'sm' | 'md' | 'lg' | 'sm' |
leadingIcon | Component | |
trailingIcon | Component | |
dot | boolean | false |
pill | boolean | false |
ui | { base?, dot?, leadingIcon?, trailingIcon? } | |
class | string |
Slots
| Slot | Description |
|---|---|
default | Replaces the label. |