Kbd

GitLab
Um elemento kbd para exibir uma tecla do teclado.

Uso

Use o slot padrão para definir o valor do Kbd.

K
<template>
  <NKbd>K</NKbd>
</template>

Valor

Use a prop value para definir o valor do Kbd.

K
<template>
  <NKbd value="K" />
</template>

Você pode passar teclas especiais para a prop value, que passam pelo composable useKbd. Por exemplo, a tecla meta é exibida como no macOS e Ctrl em outras plataformas.

<template>
  <NKbd value="meta" />
</template>

Cor

Use a prop color para alterar a cor do Kbd.

K
<template>
  <NKbd color="neutral">K</NKbd>
</template>

Variante

Use a prop variant para alterar a variante do Kbd.

K
<template>
  <NKbd color="neutral" variant="solid">K</NKbd>
</template>

Tamanho

Use a prop size para alterar o tamanho do Kbd.

K
<template>
  <NKbd size="lg">K</NKbd>
</template>

Exemplos

class prop

Use a prop class para sobrescrever os estilos base do Badge.

K
<template>
  <NKbd class="font-bold rounded-full" variant="subtle">K</NKbd>
</template>

API

Props

Prop Default Type
as'kbd'any

The element or component this component should render as.

value string
color'neutral' "neutral"
variant'outline' "outline" | "soft" | "subtle" | "solid"
size'md' "sm" | "md" | "lg"

Slots

Slot Type
default{}

Tema

app.config.ts
export default defineAppConfig({
  ui: {
    kbd: {
      base: 'inline-flex items-center justify-center px-1 rounded-sm font-medium font-sans uppercase',
      variants: {
        color: {
          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: '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'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nitro/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: {
              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: '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'
          }
        }
      }
    })
  ]
})

Changelog

No recent changes