Kbd

GitHub
A kbd element to display a keyboard key.

Usage

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

K
<template>
  <PKbd>K</PKbd>
</template>

Value

Use the value prop to set the value of the Kbd.

K
<template>
  <PKbd 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 Ctrl on other platforms.

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

Color

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

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

Variant

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

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

Size

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

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

Examples

class prop

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

K
<template>
  <PKbd class="akar:font-bold akar:rounded-full" variant="subtle">K</PKbd>
</template>

API

Props

Prop Default Type

Slots

Slot Type

Theme

We use unocss-variants to customize the theme. Read more about it in the theming guide.

Below is the theme configuration skeleton for the PKbd. Since the component is provided unstyled by default, you will need to fill in these values to apply your own custom look and feel. If you prefer to use our pre-built, opinionated styling, you can instead use our UnoCSS preset, this docs is using it as well.

app.config.ts
export default defineAppConfig({
  pohon: {
    kbd: {
      base: '',
      variants: {
        color: {
          primary: '',
          secondary: '',
          success: '',
          info: '',
          warning: '',
          error: '',
          neutral: ''
        },
        variant: {
          solid: '',
          outline: '',
          soft: '',
          subtle: ''
        },
        size: {
          sm: '',
          md: '',
          lg: ''
        }
      },
      compoundVariants: [],
      defaultVariants: {
        variant: 'outline',
        color: 'neutral',
        size: 'md'
      }
    }
  }
};
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import pohon from 'pohon-ui/vite'

export default defineAppConfig({
  pohon: {
    kbd: {
      base: '',
      variants: {
        color: {
          primary: '',
          secondary: '',
          success: '',
          info: '',
          warning: '',
          error: '',
          neutral: ''
        },
        variant: {
          solid: '',
          outline: '',
          soft: '',
          subtle: ''
        },
        size: {
          sm: '',
          md: '',
          lg: ''
        }
      },
      compoundVariants: [],
      defaultVariants: {
        variant: 'outline',
        color: 'neutral',
        size: 'md'
      }
    }
  }
};

Changelog

No recent changes