Kbd
Kbd (키보드 키)
Kbd는 키보드의 키를 표시하는 kbd 요소예요. 단축키를 안내할 때 누를 키를 깔끔하게 보여줘요.
출처: Nuxt UI
본문
기본 슬롯(default slot)을 사용해 Kbd의 값을 설정할 수 있어요.
<template>
<UKbd>
K
</UKbd>
</template>
값 설정 (Value)
value prop을 사용해 Kbd의 값을 설정할 수 있어요.
<template>
<UKbd value="K" />
</template>
특수 키를 value prop에 전달하면 useKbd 컴포저블을 거쳐 표시돼요. 예를 들어 meta 키는 macOS에서는 ⌘로, 다른 플랫폼에서는 Ctrl로 표시돼요.
<template>
<UKbd value="meta" />
</template>
색상 (Color)
color prop을 사용해 Kbd의 색상을 변경할 수 있어요.
<template>
<UKbd color="neutral">
K
</UKbd>
</template>
변형 (Variant)
variant prop을 사용해 Kbd의 변형을 변경할 수 있어요.
<template>
<UKbd color="neutral" variant="solid">
K
</UKbd>
</template>
크기 (Size)
size prop을 사용해 Kbd의 크기를 변경할 수 있어요.
<template>
<UKbd size="lg">
K
</UKbd>
</template>
예제 (Examples)
class prop
class prop을 사용해 Badge의 기본 스타일을 덮어쓸 수 있어요.
<template>
<UKbd class="font-bold rounded-full" variant="subtle">
K
</UKbd>
</template>
API
Props
/**
* Props for the Kbd component
*/
interface KbdProps {
/**
* The element or component this component should render as.
* @default 'kbd'
*/
as?: any;
value?: string | undefined;
/**
* @default 'neutral'
*/
color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* @default 'outline'
*/
variant?: "outline" | "soft" | "subtle" | "solid" | undefined;
/**
* @default 'md'
*/
size?: "sm" | "md" | "lg" | undefined;
ui?: { base?: any; } | undefined;
}
Slots
/**
* Slots for the Kbd component
*/
interface KbdSlots {
default(): any;
}
테마 (Theme)
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: 'secondary',
variant: 'solid',
class: 'text-inverted bg-secondary'
},
{
color: 'success',
variant: 'solid',
class: 'text-inverted bg-success'
},
{
color: 'info',
variant: 'solid',
class: 'text-inverted bg-info'
},
{
color: 'warning',
variant: 'solid',
class: 'text-inverted bg-warning'
},
{
color: 'error',
variant: 'solid',
class: 'text-inverted bg-error'
},
{
color: 'primary',
variant: 'outline',
class: 'ring ring-inset ring-primary/50 text-primary'
},
{
color: 'secondary',
variant: 'outline',
class: 'ring ring-inset ring-secondary/50 text-secondary'
},
{
color: 'success',
variant: 'outline',
class: 'ring ring-inset ring-success/50 text-success'
},
{
color: 'info',
variant: 'outline',
class: 'ring ring-inset ring-info/50 text-info'
},
{
color: 'warning',
variant: 'outline',
class: 'ring ring-inset ring-warning/50 text-warning'
},
{
color: 'error',
variant: 'outline',
class: 'ring ring-inset ring-error/50 text-error'
},
{
color: 'primary',
variant: 'soft',
class: 'text-primary bg-primary/10'
},
{
color: 'secondary',
variant: 'soft',
class: 'text-secondary bg-secondary/10'
},
{
color: 'success',
variant: 'soft',
class: 'text-success bg-success/10'
},
{
color: 'info',
variant: 'soft',
class: 'text-info bg-info/10'
},
{
color: 'warning',
variant: 'soft',
class: 'text-warning bg-warning/10'
},
{
color: 'error',
variant: 'soft',
class: 'text-error bg-error/10'
},
{
color: 'primary',
variant: 'subtle',
class: 'text-primary ring ring-inset ring-primary/25 bg-primary/10'
},
{
color: 'secondary',
variant: 'subtle',
class: 'text-secondary ring ring-inset ring-secondary/25 bg-secondary/10'
},
{
color: 'success',
variant: 'subtle',
class: 'text-success ring ring-inset ring-success/25 bg-success/10'
},
{
color: 'info',
variant: 'subtle',
class: 'text-info ring ring-inset ring-info/25 bg-info/10'
},
{
color: 'warning',
variant: 'subtle',
class: 'text-warning ring ring-inset ring-warning/25 bg-warning/10'
},
{
color: 'error',
variant: 'subtle',
class: 'text-error ring ring-inset ring-error/25 bg-error/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'
}
}
}
})