使用默认插槽设置 Kbd 的值。
<template>
<UKbd>K</UKbd>
</template>
使用 value 属性设置 Kbd 的值。
<template>
<UKbd value="K" />
</template>
你可以向 value 属性传递特殊按键,这些按键将通过useKbd组合式函数进行处理。例如,meta 键在 macOS 上显示为 ⌘,在其他平台上显示为 Ctrl。
<template>
<UKbd value="meta" />
</template>
使用 color 属性更改 Kbd 的颜色。
<template>
<UKbd color="neutral">K</UKbd>
</template>
使用 variant 属性更改 Kbd 的变体。
<template>
<UKbd color="neutral" variant="solid">K</UKbd>
</template>
使用 size 属性更改 Kbd 的大小。
<template>
<UKbd size="lg">K</UKbd>
</template>
class 属性使用 class 属性覆盖 Badge 的基本样式。
<template>
<UKbd class="font-bold rounded-full" variant="subtle">K</UKbd>
</template>
| 属性 | 默认值 | 类型 |
|---|---|---|
as |
|
此组件应渲染为的元素或组件。 |
value |
| |
color |
|
|
variant |
|
|
尺寸 |
|
|
| 插槽 | 类型 |
|---|---|
default |
|
export default defineAppConfig({
ui: {
kbd: {
base: 'inline-flex items-center justify-center px-1 rounded-sm font-medium font-sans uppercase',
variants: {
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
solid: '',
outline: '',
soft: '',
subtle: ''
},
size: {
sm: 'h-4 min-w-[16px] text-[10px]',
md: 'h-5 min-w-[20px] text-[11px]',
lg: 'h-6 min-w-[24px] text-[12px]'
}
},
compoundVariants: [
{
color: 'primary',
variant: 'solid',
class: 'text-inverted bg-primary'
},
{
color: 'primary',
variant: 'outline',
class: 'ring ring-inset ring-primary/50 text-primary'
},
{
color: 'primary',
variant: 'soft',
class: 'text-primary bg-primary/10'
},
{
color: 'primary',
variant: 'subtle',
class: 'text-primary ring ring-inset ring-primary/25 bg-primary/10'
},
{
color: 'neutral',
variant: 'solid',
class: 'text-inverted bg-inverted'
},
{
color: 'neutral',
variant: 'outline',
class: 'ring ring-inset ring-accented text-default bg-default'
},
{
color: 'neutral',
variant: 'soft',
class: 'text-default bg-elevated'
},
{
color: 'neutral',
variant: 'subtle',
class: 'ring ring-inset ring-accented text-default bg-elevated'
}
],
defaultVariants: {
variant: 'outline',
color: 'neutral',
size: 'md'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
kbd: {
base: 'inline-flex items-center justify-center px-1 rounded-sm font-medium font-sans uppercase',
variants: {
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
solid: '',
outline: '',
soft: '',
subtle: ''
},
size: {
sm: 'h-4 min-w-[16px] text-[10px]',
md: 'h-5 min-w-[20px] text-[11px]',
lg: 'h-6 min-w-[24px] text-[12px]'
}
},
compoundVariants: [
{
color: 'primary',
variant: 'solid',
class: 'text-inverted bg-primary'
},
{
color: 'primary',
variant: 'outline',
class: 'ring ring-inset ring-primary/50 text-primary'
},
{
color: 'primary',
variant: 'soft',
class: 'text-primary bg-primary/10'
},
{
color: 'primary',
variant: 'subtle',
class: 'text-primary ring ring-inset ring-primary/25 bg-primary/10'
},
{
color: 'neutral',
variant: 'solid',
class: 'text-inverted bg-inverted'
},
{
color: 'neutral',
variant: 'outline',
class: 'ring ring-inset ring-accented text-default bg-default'
},
{
color: 'neutral',
variant: 'soft',
class: 'text-default bg-elevated'
},
{
color: 'neutral',
variant: 'subtle',
class: 'ring ring-inset ring-accented text-default bg-elevated'
}
],
defaultVariants: {
variant: 'outline',
color: 'neutral',
size: 'md'
}
}
}
})
]
})