Skip to main content

Kbd

Semantic keyboard-shortcut pill covering: semantic <kbd> element, sizes, variants, key sequences, platform-aware modifier symbols.

Live Preview

Adjust size and variant to see the single Kbd and multi-key sequences update instantly.

KKCtrlAlt
tsx
1<Kbd size="md" variant="default">K</Kbd>2<KbdSequence keys={['cmd', 'shift', 'K']} size="md" variant="default" />3<KbdSequence keys={['ctrl', 'alt', 'delete']} size="md" variant="default" />

Installation

Install the Aidash Components package using your preferred package manager.

$ pnpm add @aidash/components

Import

Import Kbd and KbdSequence into your file.

tsx
import { Kbd, KbdSequence } from '@/components/aidash/kbd';

Basic Usage

Render a single key with the semantic <kbd> element.

K
tsx
1<Kbd>K</Kbd>

Sizes

Three sizes to fit inline copy, buttons, or callouts.

SmMdLg
tsx
1<Kbd size="sm">Sm</Kbd>2<Kbd size="md">Md</Kbd>3<Kbd size="lg">Lg</Kbd>

Variants

Default uses a subtle two-tone key look; outline drops the shadow; ghost drops the border.

DefaultOutlineGhost
tsx
1<Kbd variant="default">Default</Kbd>2<Kbd variant="outline">Outline</Kbd>3<Kbd variant="ghost">Ghost</Kbd>

Key Sequences

Compose multi-key shortcuts with KbdSequence. Symbolic modifiers resolve to glyphs, and 'mod' picks the right modifier per platform.

CtrlPCtrlK
tsx
1<KbdSequence keys={['mod', 'shift', 'P']} />2<KbdSequence keys={['mod', 'K']} />3<KbdSequence keys={['shift', 'enter']} separator="then" />

Modifier Keys

Symbolic key names resolve to glyphs. The 'mod' and 'alt' entries adapt to the visitor's platform on the client.

InputMacOther
'mod'Ctrl
'cmd'
'ctrl'CtrlCtrl
'shift'
'alt'Alt
'enter'
'escape'EscEsc
'tab'
'space'
'up'↑ ↓ ← →↑ ↓ ← →
'backspace'
'delete'
tsx
1<KbdSequence keys={['mod', 'K']} />2<KbdSequence keys={['shift', 'tab']} />3<KbdSequence keys={['alt', 'enter']} />4<KbdSequence keys={['up', 'down', 'left', 'right']} separator="," />

In Context

Kbd is designed to sit inline within body copy.

Press CtrlK to open the command palette.

Use CtrlP to jump to a file, or hit Esc to dismiss any open dialog.

tsx
1<p>2  Press <KbdSequence keys={['mod', 'K']} size="sm" /> to open the command palette.3</p>4<p>5  Use <KbdSequence keys={['mod', 'shift', 'P']} size="sm" /> to jump to a file,6  or hit <Kbd size="sm">Esc</Kbd> to dismiss any open dialog.7</p>

Accessibility

Kbd leans on native HTML semantics and readable glyph mappings.

Semantic <kbd> element

Renders the native <kbd> element so screen readers and assistive tech announce it as user input rather than plain text.

Platform-aware modifier symbols

mod resolves to on Mac and Ctrl elsewhere, keeping labels aligned with what users see on their keyboard.

Screen-reader-friendly text alternative

When a glyph alone might be ambiguous (e.g. an arrow key), wrap the sequence in a labelled container or pair it with a visually-hidden description so the shortcut is announced clearly.

tsx
1<span>2  <span className="sr-only">Command shift K</span>3  <KbdSequence keys={['mod', 'shift', 'K']} aria-hidden />4</span>

API Reference

Props for Kbd and KbdSequence.

KbdProps
PropTypeDefaultDescription
childrenReact.ReactNodeContent rendered inside the key pill — text or a pre-formatted symbol.
size'sm' | 'md' | 'lg''md'Size of the key pill.
variant'default' | 'ghost' | 'outline''default'Visual variant of the key.
classNamestring''Additional CSS classes appended to the root <kbd> element.
KbdSequenceProps
PropTypeDefaultDescription
keys(string | KbdSequenceKey)[]Ordered list of keys. Symbolic names like 'mod', 'shift', 'enter' resolve to glyphs; other strings render verbatim.
size'sm' | 'md' | 'lg''md'Size applied to every child Kbd.
variant'default' | 'ghost' | 'outline''default'Variant applied to every child Kbd.
separatorReact.ReactNode'+'Node rendered between each key.
classNamestring''Additional CSS classes appended to the root wrapper.
Note
Platform detection runs in a client-side effect. Server-rendered markup uses the non-Mac defaults so hydration stays stable; the mapping updates on mount.

Other components that work well alongside Kbd.