Skip to content

Kbd

Semantic <kbd> wrapper component that visually separates keyboard shortcuts from regular text through neo-brutalist styling, making documentation and command prompts clear at a glance.

Demo

Preview

常用快捷键

+K打开命令面板
Ctrl+S保存
Shift+Tab反向缩进

尺寸

EscEnterSpace

变体

EscEnterTabSpace

Installation

pnpm dlx brutx-vue@latest add kbd

Usage

vue
<script setup>
import { Kbd } from 'brutx-ui-vue'
</script>

<template>
    <!-- Single key -->
    <Kbd>Enter</Kbd>

    <!-- Key combination -->
    <div class="flex items-center gap-1">
        <Kbd>⌘</Kbd>
        <span>+</span>
        <Kbd>K</Kbd>
    </div>

    <!-- Sizes -->
    <Kbd size="sm">Esc</Kbd>
    <Kbd size="md">Tab</Kbd>
    <Kbd size="lg">Space</Kbd>
</template>

Variants

VariantDescription
defaultNeutral background with standard foreground text
primaryPrimary (coral) background with high-contrast foreground
secondarySecondary (mint) background
accentAccent (yellow) background
vue
<script setup>
import { Kbd } from 'brutx-ui-vue'
</script>

<template>
    <div class="flex items-center gap-2">
        <Kbd variant="default">Esc</Kbd>
        <Kbd variant="primary">Enter</Kbd>
        <Kbd variant="secondary">Tab</Kbd>
        <Kbd variant="accent">Space</Kbd>
    </div>
</template>

Sizes

SizeDescription
smSmall size, suitable for inline compact scenarios
mdDefault size
lgLarge size, suitable for standalone display

Props

PropTypeDefaultDescription
variant'default' | 'primary' | 'secondary' | 'accent''default'Key color variant
size'sm' | 'md' | 'lg''md'Key size
classstring | undefinedundefinedCustom style class, merged with the component's default styles

Slots

SlotScopeDescription
defaultKey content (text or symbol)

Accessibility

  • Semantic Markup: Uses the native <kbd> element for rendering, so screen readers can correctly identify it as a keyboard key
  • Visual Presentation: Visually separates keys from regular text through brutalist styling, improving readability
  • Key Combination Display: Supports displaying keyboard shortcuts by combining multiple <Kbd> components with clear semantics

Brute force builds.