Page:
Kbd
Pages
Accordion
AccordionItem
Alert
Avatar
Badge
BarChart
Button
ButtonGroup
Card
Changelog
ChartLegend
Checkbox
CodeEditor
Collapsible
Combobox
CommandPalette
ContextMenu
CopyButton
DatePicker
Dialog
DonutChart
Drawer
Field
FileInput
FileList
Forms
Gauge
Getting started
Heatmap
Home
Image
InlineEdit
Input
Kbd
Label
LineChart
Menu
MultiSelect
NumberInput
Overlays
Pagination
Popover
Progress
RadioGroup
Scroller
Select
Separator
ShareBar
Sheet
Skeleton
Slider
Sparkline
Spinner
StatCard
Switch
Table
Tabs
TagsInput
Textarea
Theming
Toaster
Toggle
Tooltip
Tree
No results
2
Kbd
L4stIdi0t edited this page 2026-10-06 12:08:41 +02:00
Kbd
Renders a keyboard shortcut with OS-appropriate glyphs: ⌘⇧⌥ on macOS and Ctrl/Shift/Alt everywhere else.
Pass tokens ('mod', 'shift', 'K') rather than symbols, so one shortcut definition is right on both platforms. Each keycap goes down while its key is held, so a reader trying a shortcut sees it register. That is display only: Kbd never handles the shortcut.
Navigation
<script lang="ts">
import { Kbd } from '@l4st/driftwood';
</script>
| Light | Dark |
|---|---|
![]() |
![]() |
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
keys |
string[] | string |
— | Modifiers are named, not typed: mod renders ⌘ on macOS and Ctrl elsewhere. An array, or one string joined with + ('mod+shift+p'). |
reactive |
boolean |
true |
Press a keycap down while its key is held. Turn off for a shortcut shown as plain reference. |
class |
string |
— | Merged with the component's own classes, last — so yours win. |
children |
Snippet |
— | Raw content, when keys is not enough — a single key, styled. |
Example
The markup behind the screenshot above, lifted from src/routes/shots/ — so it
compiles, and it is exactly what produced the image.
<span class="flex items-center gap-2">Search <Kbd keys={['mod', 'K']} /></span>
<span class="flex items-center gap-2">Palette <Kbd keys={['mod', 'shift', 'P']} /></span>
<span class="flex items-center gap-2">Dismiss <Kbd keys={['esc']} /></span>
Notes
Notes
- A keycap goes down while its key is held. Every
Kbdon the page shares one pair of window listeners. This is display only:Kbddoes not run anything. Passreactive={false}where a moving keycap would distract, such as a long reference table. keysis an array or one string.keys={['mod', 'shift', 'P']}andkeys="mod+shift+p"draw the same thing. The string form is the notation CommandPalette'sshortcutprop takes, and whatmatchesShortcut(e, 'mod+shift+p')tests a keydown against, so one constant can be shown and listened for. Write the plus key asplus.- macOS reports no keyup for a key released while ⌘ is held. The K in ⌘K therefore stays down until ⌘ is let go. That is the platform, not a stuck state.
Navigation · Tree · Tabs · Pagination · CommandPalette
driftwood
Layout
Actions
Forms
- Field
- Input
- FileInput
- FileList
- Textarea
- CodeEditor
- Combobox
- RadioGroup
- NumberInput
- InlineEdit
- Label
- Select
- MultiSelect
- DatePicker
- TagsInput
- Checkbox
- Switch
- Slider
Feedback
Charts
Overlays
Navigation
Generated from the source by pnpm wiki · repository · v0.24.0

