Badge
Usage
Label
Use the default slot to set the label of the Badge.
<template>
<UBadge>Badge</UBadge>
</template>
You can achieve the same result by using the label
prop.
<template>
<UBadge label="Badge" />
</template>
Color
Use the color
prop to change the color of the Badge.
<template>
<UBadge color="neutral">Badge</UBadge>
</template>
Variant
Use the variant
props to change the variant of the Badge.
<template>
<UBadge color="neutral" variant="outline">Badge</UBadge>
</template>
Size
Use the size
prop to change the size of the Badge.
<template>
<UBadge size="xl">Badge</UBadge>
</template>
Icon
Use the icon
prop to show an Icon inside the Badge.
<template>
<UBadge icon="i-lucide-rocket">Badge</UBadge>
</template>
Use the leading
and trailing
props to set the icon position or the leading-icon
and trailing-icon
props to set a different icon for each position.
<template>
<UBadge trailing-icon="i-lucide-arrow-right">Badge</UBadge>
</template>
Avatar
Use the avatar
prop to show an Avatar inside the Badge.
<template>
<UBadge
:avatar="{
src: 'https://github.com/nuxt.png'
}"
color="neutral"
variant="outline"
>
Badge
</UBadge>
</template>
Examples
class
prop
Use the class
prop to override the base styles of the Badge.
<template>
<UBadge class="font-bold rounded-full">Badge</UBadge>
</template>
API
Props
Prop | Default | Type |
---|---|---|
as |
|
The element or component this component should render as. |
label |
| |
color |
|
|
variant |
|
|
size |
|
|
icon |
Display an icon based on the | |
avatar |
Display an avatar on the left side.
| |
leading |
When | |
leadingIcon |
Display an icon on the left side. | |
trailing |
When | |
trailingIcon |
Display an icon on the right side. | |
ui |
|
Slots
Slot | Type |
---|---|
leading |
|
default |
|
trailing |
|
Theme
export default defineAppConfig({
uiPro: {
prose: {
badge: {
base: 'rounded-full'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
uiPro: {
prose: {
badge: {
base: 'rounded-full'
}
}
}
})
]
})