Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Utilities

Kbd

A native keyboard-input hint for shortcuts and commands.

Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.

Interactive showcase

SearchCtrlKSaveCtrlSCloseEscCommand⌘

Install

Run in your project
bunx --bun @getweini/cli@latest add kbd

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Search: Ctrl + K

Vue
<script setup lang="ts">
import Kbd from './components/ui/kbd/Kbd.vue'
</script>

<template>
  <p>Search:&nbsp;<Kbd>Ctrl</Kbd>&nbsp;+&nbsp;<Kbd>K</Kbd></p>
</template>

Use the #icon slot for a decorative icon beside a key label. Give icon-only hints an accessible name. Kbd displays shortcuts; bind the actual keyboard behavior in your application.

When to use it

Shortcut help

Show a key combination next to the command it invokes.

Instructional text

Explain which key dismisses an overlay or confirms a choice.

More examples

Shortcut list

Show each key as a separate semantic keycap.

Shortcut list
<script setup lang="ts">
import Kbd from './components/ui/kbd/Kbd.vue'
</script>

<template>
  <p>Search:&nbsp;<Kbd>Ctrl</Kbd>&nbsp;+&nbsp;<Kbd>K</Kbd></p>
</template>

Compact hint

Use the small size in a dense command menu.

Compact hint
<script setup lang="ts">
import Kbd from './components/ui/kbd/Kbd.vue'
</script>

<template>
  <span>Close menu&nbsp;<Kbd size="sm">Esc</Kbd></span>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Kbd

Complete API for Kbd
NameType or signatureDefaultWhat it does
sizeprop"sm" | "md" | undefined"md"Choose the visual size. Medium is the usual default where available.
defaultslot(() => unknown) | undefinedOptionalContent shown inside Kbd.
iconslot(() => unknown) | undefinedOptionalContent for the icon area of Kbd.
Public type definitions
Public types
// packages/frameworks/vue/components/kbd/types.ts
// ------- TYPES -------

export interface KbdProps {
  size?: 'sm' | 'md'
}

Implementation notes

  • Kbd presents a shortcut; the application must implement the actual keyboard behavior.
  • Use platform-appropriate key names in instructions shown to users.

Accessibility and localization

  • For an icon-only key hint, provide an accessible name and hide the decorative icon.

Source contract and editing guidance