On this page

Kbd

Live examples of Kbd, with the exact Vue file that renders each one.

Every example is a complete Vue file. Copy it into an app that has the registry installed, or open it in StackBlitz.

A list of shortcuts

KbdGroup holds keys pressed together. The plus signs are hidden from screen readers, which read each key.

Search orders
CtrlK
New mapping
CtrlShiftM
Close panel
Esc
KbdShortcuts.vue
<script setup lang="ts">
import { Kbd, KbdGroup } from '@/components/ui/kbd'

const shortcuts = [
  { action: 'Search orders', keys: ['Ctrl', 'K'] },
  { action: 'New mapping', keys: ['Ctrl', 'Shift', 'M'] },
  { action: 'Close panel', keys: ['Esc'] },
]
</script>

<template>
  <dl class="m-0 grid w-full max-w-80 grid-cols-[1fr_auto] items-center gap-y-(--bh-space-100) [font:var(--bh-font-body-default)]">
    <template v-for="shortcut in shortcuts" :key="shortcut.action">
      <dt class="text-(--bh-color-text)">{{ shortcut.action }}</dt>
      <dd class="m-0">
        <KbdGroup>
          <template v-for="(key, index) in shortcut.keys" :key="key">
            <span v-if="index > 0" aria-hidden="true" class="text-(--bh-color-text-subtle)">+</span>
            <Kbd>{{ key }}</Kbd>
          </template>
        </KbdGroup>
      </dd>
    </template>
  </dl>
</template>

A key in a sentence

A key cap is 20 px high, so it fits in a line of body text.

Press / to jump to the search box, then Enter to open the first order.

KbdInline.vue
<script setup lang="ts">
import { Kbd } from '@/components/ui/kbd'
</script>

<template>
  <p class="m-0 max-w-120 text-(--bh-color-text) [font:var(--bh-font-body-default)]">
    Press <Kbd>/</Kbd> to jump to the search box, then <Kbd>Enter</Kbd> to open the first order.
  </p>
</template>