Envolva qualquer componente com um Chip para exibir um indicador.
<template>
<NChip>
<NButton icon="i-lucide-mail" color="neutral" variant="subtle" />
</NChip>
</template>
Use a prop color para alterar a cor do Chip.
<template>
<NChip color="neutral">
<NButton icon="i-lucide-mail" color="neutral" variant="subtle" />
</NChip>
</template>
Use a prop size para alterar o tamanho do Chip.
<template>
<NChip size="3xl">
<NButton icon="i-lucide-mail" color="neutral" variant="subtle" />
</NChip>
</template>
Use a prop text para definir o texto do Chip.
<template>
<NChip :text="5" size="3xl">
<NButton icon="i-lucide-mail" color="neutral" variant="subtle" />
</NChip>
</template>
Use a prop position para alterar a posição do Chip.
<template>
<NChip position="bottom-left">
<NButton icon="i-lucide-mail" color="neutral" variant="subtle" />
</NChip>
</template>
Use a prop inset para exibir o Chip dentro do componente. Isso é útil ao lidar com componentes arredondados.
<template>
<NChip inset>
<NAvatar src="https://github.com/benjamincanac.png" loading="lazy" />
</NChip>
</template>
Use a prop standalone junto com a prop inset para exibir o Chip inline.
<template>
<NChip standalone inset />
</template>
Você pode controlar a visibilidade do Chip usando a prop show.
offline.| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
text | string | numberDisplay some text inside the chip. | |
color | 'primary' | "primary" | "secondary" | "accent" | "success" | "info" | "warning" | "error" | "neutral" |
size | 'md' | "xs" | "sm" | "md" | "lg" | "xl" | "3xs" | "2xs" | "2xl" | "3xl" |
position | 'top-right' | "top-right" | "bottom-right" | "top-left" | "bottom-left"The position of the chip. |
inset | false | boolean When |
standalone | false | boolean When |
show | true | boolean |
ui | { root?: SlotClass; base?: SlotClass; } |
| Slot | Type |
|---|---|
default | {} |
content | {} |
| Event | Type |
|---|---|
update:show | [value: boolean] |
export default defineAppConfig({
ui: {
chip: {
slots: {
root: 'relative inline-flex items-center justify-center shrink-0',
base: 'rounded-full ring ring-bg flex items-center justify-center text-inverted font-medium whitespace-nowrap'
},
variants: {
color: {
primary: 'bg-primary',
secondary: 'bg-secondary',
accent: 'bg-accent',
success: 'bg-success',
info: 'bg-info',
warning: 'bg-warning',
error: 'bg-error',
neutral: 'bg-inverted'
},
size: {
'3xs': 'h-[4px] min-w-[4px] text-[4px]',
'2xs': 'h-[5px] min-w-[5px] text-[5px]',
xs: 'h-[6px] min-w-[6px] text-[6px]',
sm: 'h-[7px] min-w-[7px] text-[7px]',
md: 'h-[8px] min-w-[8px] text-[8px]',
lg: 'h-[9px] min-w-[9px] text-[9px]',
xl: 'h-[10px] min-w-[10px] text-[10px]',
'2xl': 'h-[11px] min-w-[11px] text-[11px]',
'3xl': 'h-[12px] min-w-[12px] text-[12px]'
},
position: {
'top-right': 'top-0 right-0',
'bottom-right': 'bottom-0 right-0',
'top-left': 'top-0 left-0',
'bottom-left': 'bottom-0 left-0'
},
inset: {
false: ''
},
standalone: {
false: 'absolute'
}
},
compoundVariants: [
{
position: 'top-right',
inset: false,
class: '-translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'bottom-right',
inset: false,
class: 'translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'top-left',
inset: false,
class: '-translate-y-1/2 -translate-x-1/2 transform'
},
{
position: 'bottom-left',
inset: false,
class: 'translate-y-1/2 -translate-x-1/2 transform'
}
],
defaultVariants: {
size: 'md',
color: 'primary',
position: 'top-right'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
chip: {
slots: {
root: 'relative inline-flex items-center justify-center shrink-0',
base: 'rounded-full ring ring-bg flex items-center justify-center text-inverted font-medium whitespace-nowrap'
},
variants: {
color: {
primary: 'bg-primary',
secondary: 'bg-secondary',
accent: 'bg-accent',
success: 'bg-success',
info: 'bg-info',
warning: 'bg-warning',
error: 'bg-error',
neutral: 'bg-inverted'
},
size: {
'3xs': 'h-[4px] min-w-[4px] text-[4px]',
'2xs': 'h-[5px] min-w-[5px] text-[5px]',
xs: 'h-[6px] min-w-[6px] text-[6px]',
sm: 'h-[7px] min-w-[7px] text-[7px]',
md: 'h-[8px] min-w-[8px] text-[8px]',
lg: 'h-[9px] min-w-[9px] text-[9px]',
xl: 'h-[10px] min-w-[10px] text-[10px]',
'2xl': 'h-[11px] min-w-[11px] text-[11px]',
'3xl': 'h-[12px] min-w-[12px] text-[12px]'
},
position: {
'top-right': 'top-0 right-0',
'bottom-right': 'bottom-0 right-0',
'top-left': 'top-0 left-0',
'bottom-left': 'bottom-0 left-0'
},
inset: {
false: ''
},
standalone: {
false: 'absolute'
}
},
compoundVariants: [
{
position: 'top-right',
inset: false,
class: '-translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'bottom-right',
inset: false,
class: 'translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'top-left',
inset: false,
class: '-translate-y-1/2 -translate-x-1/2 transform'
},
{
position: 'bottom-left',
inset: false,
class: 'translate-y-1/2 -translate-x-1/2 transform'
}
],
defaultVariants: {
size: 'md',
color: 'primary',
position: 'top-right'
}
}
}
})
]
})