Keyboard Key

A kbd element to display a keyboard key.

Usage

Value

Use the default slot to set the value of the Kbd.

K
<template>
  <UKbd>K</UKbd>
</template>

You can achieve the same result by using the value prop.

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

You can pass special keys to the value prop that goes through the useKbd composable. For example, the meta key displays as ⌘ on macOS and ⊞ on other platforms.

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

Variant

Use the variant prop to change the variant of the Kbd.

K
<template>
  <UKbd variant="solid">K</UKbd>
</template>

Size

Use the size prop to change the size of the Kbd.

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

Examples

class prop

Use the class prop to override the base styles of the Badge.

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

API

Props

Prop Default Type
as

'kbd'

any

The element or component this component should render as.

value

string

variant

'outline'

"solid" | "outline" | "subtle"

size

'md'

"md" | "sm" | "lg"

Slots

Slot Type
default

{}

Theme

app.config.ts
export default defineAppConfig({
  uiPro: {
    prose: {
      kbd: {
        base: 'align-text-top'
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      uiPro: {
        prose: {
          kbd: {
            base: 'align-text-top'
          }
        }
      }
    })
  ]
})