Kbd
A key, or keys pressed together.
⌘⇧⌥⌃Ctrl+B
kbd-demo.tsx
import { Kbd, KbdGroup } from './ui/kbd.tsx'
export default () => (
<div style="display: grid; gap: 1rem; justify-items: center">
<KbdGroup>
<Kbd>⌘</Kbd>
<Kbd>⇧</Kbd>
<Kbd>⌥</Kbd>
<Kbd>⌃</Kbd>
</KbdGroup>
<KbdGroup>
<Kbd>Ctrl</Kbd>
<span>+</span>
<Kbd>B</Kbd>
</KbdGroup>
</div>
)
Installation
dui add kbdOr copy ui/kbd.tsx and ui/kbd.css into your project, with lib/jsx/jsx-runtime.ts, lib/jsx/jsx-dev-runtime.ts, lib/css.d.ts, and lib/theme.css.
Examples
In text
Press / to search, or Esc to close a dialog.
kbd-in-text.tsx
import { Kbd } from './ui/kbd.tsx'
export default () => (
<p style="margin: 0; color: var(--muted-foreground); font-size: 0.875rem">
Press <Kbd>/</Kbd> to search, or <Kbd>Esc</Kbd> to close a dialog.
</p>
)
Compared to shadcn/ui
- The same
KbdandKbdGroup, on<kbd>.