Veil UI
Components

Kbd

Displays a keyboard key or shortcut.

Installation

$ npx veil-ui@latest add kbd

Usage

import { Kbd } from "@/components/ui/kbd";

<Kbd>⌘</Kbd>;

Examples

Basic

⌘K

In a sentence

Press Shift + ? to open the shortcut menu.

In a menu row

Search⌘K

API reference

PropTypeDefaultDescription
...propsReact.ComponentProps<"kbd">—All native kbd attributes.

Accessibility

  • Renders a real <kbd> element so assistive technology can identify it.
  • Spell out shortcuts in the surrounding text when the glyphs may be ambiguous.

Vue and plain HTML

This component also ships for Vue (Reka UI) and plain HTML. Install it with npx veil-ui add kbd --framework vue or switch the framework in components.json.

<script setup lang="ts">
import { cn } from "@/lib/utils";

const props = defineProps<{ class?: string }>();
</script>

<template>
  <kbd
    data-slot="kbd"
    :class="
      cn(
        'pointer-events-none inline-flex h-5 min-w-5 select-none items-center justify-center gap-0.5 rounded border bg-muted px-1 font-mono text-[10px] font-medium text-muted-foreground',
        props.class,
      )
    "
  >
    <slot />
  </kbd>
</template>

On this page