Data display
IKbd
A keyboard shortcut, drawn as one chip per key.
Display only: it shows what to press and binds nothing.
The mod key
mod renders as ⌘ on Apple platforms and Ctrl everywhere else. It is the same vocabulary matchesHotkey reads, so one string can drive both what you bind and what you show:
// bound
if (matchesHotkey(event, 'mod+k'))
open()<!-- shown -->
<IKbd keys="mod+k" />The platform is resolved after mount, so server-rendered markup shows Ctrl until the component hydrates.
Keys it knows
Modifiers: mod, meta, cmd, ctrl, shift, alt / option.
Named keys: enter, escape, backspace, delete, tab, space, capslock, pageup, pagedown, home, end, and the arrows as either up or arrowup.
Anything else prints as given, with a lone character capitalised.
Joined
joined puts a + between the chips, for a combination that needs spelling out.
Sizes
In context
ICommandPalette renders its items' shortcuts with this component, so palette rows and chips beside a button match.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
keys | string | string[] | [] | 'mod+k', or ['mod', 'k'] |
size | 'xs' | 'sm' | 'md' | 'sm' | |
joined | boolean | false | Draw a + between chips |
ariaLabel | string | the spoken combination | Overrides the spoken name |
unstyled | boolean | — | Skip built-in classes |
ui | { root?, key?, separator? } | — | Per-slot class overrides |
Slots
| Slot | Props | Description |
|---|---|---|
key | { item } | Replaces a chip's contents |
Helpers
parseHotkey(keys, isApple) and useApplePlatform() are exported for building your own shortcut UI.
Accessibility
The chips are hidden from assistive technology and the group carries the spoken form instead: mod+shift+k announces as "Command Shift K" on a Mac and "Control Shift K" elsewhere. Override it with ariaLabel.
When the shortcut belongs to a specific control, put aria-keyshortcuts on that control as well.