Badge
Usage
Use the default slot to set the label of the Badge.
<template>
<PBadge>Badge</PBadge>
</template>
Label
Use the label prop to set the label of the Badge.
<template>
<PBadge label="Badge" />
</template>
Color
Use the color prop to change the color of the Badge.
<template>
<PBadge color="neutral">Badge</PBadge>
</template>
Variant
Use the variant props to change the variant of the Badge.
<template>
<PBadge color="neutral" variant="outline">Badge</PBadge>
</template>
Size
Use the size prop to change the size of the Badge.
<template>
<PBadge size="xl">Badge</PBadge>
</template>
Icon
Use the icon prop to show an Icon inside the Badge.
<template>
<PBadge icon="i-lucide:rocket" size="md" color="primary" variant="solid">Badge</PBadge>
</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>
<PBadge trailing-icon="i-lucide:arrow-right" size="md">Badge</PBadge>
</template>
Avatar
Use the avatar prop to show an Avatar inside the Badge.
<template>
<PBadge
:avatar="{
src: 'https://github.com/nuxt.png'
}"
size="md"
color="neutral"
variant="outline"
>
Badge
</PBadge>
</template>
Examples
class prop
Use the class prop to override the base styles of the Badge.
<template>
<PBadge class="font-bold rounded-full">Badge</PBadge>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
as | 'span' | anyThe element or component this component should render as. |
icon | string | objectDisplay an icon based on the | |
avatar | PAvatarPropsDisplay an avatar on the left side.
| |
leadingIcon | string | objectDisplay an icon on the left side. | |
trailingIcon | string | objectDisplay an icon on the right side. | |
label | string | number | |
color | 'primary' | "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" |
variant | 'solid' | "solid" | "outline" | "soft" | "subtle" |
size | 'md' | "md" | "xs" | "sm" | "lg" | "xl" |
leading | booleanWhen | |
trailing | booleanWhen | |
square | booleanRender the badge with equal padding on all sides. | |
pohon | { base?: ClassValue; label?: ClassValue; leadingIcon?: ClassValue; leadingAvatar?: ClassValue; leadingAvatarSize?: ClassValue; trailingIcon?: ClassValue; } |
Slots
| Slot | Type |
|---|---|
leading | { pohon: object; } |
default | { pohon: object; } |
trailing | { pohon: object; } |
Theme
Below is the theme configuration skeleton for the PBadge. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.
export default defineAppConfig({
pohon: {
badge: {
slots: {
base: '',
label: '',
leadingIcon: '',
leadingAvatar: '',
leadingAvatarSize: '',
trailingIcon: ''
},
variants: {
fieldGroup: {
horizontal: '',
vertical: ''
},
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
solid: '',
outline: '',
soft: '',
subtle: ''
},
size: {
xs: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
sm: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
md: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
lg: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
xl: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
}
},
square: {
true: ''
}
},
compoundVariants: [],
defaultVariants: {
color: 'primary',
variant: 'solid',
size: 'md'
}
}
}
};
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'
export default defineAppConfig({
pohon: {
badge: {
slots: {
base: '',
label: '',
leadingIcon: '',
leadingAvatar: '',
leadingAvatarSize: '',
trailingIcon: ''
},
variants: {
fieldGroup: {
horizontal: '',
vertical: ''
},
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
solid: '',
outline: '',
soft: '',
subtle: ''
},
size: {
xs: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
sm: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
md: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
lg: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
},
xl: {
base: '',
leadingIcon: '',
leadingAvatarSize: '',
trailingIcon: ''
}
},
square: {
true: ''
}
},
compoundVariants: [],
defaultVariants: {
color: 'primary',
variant: 'solid',
size: 'md'
}
}
}
};