Skip to content

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:

ts
// bound
if (matchesHotkey(event, 'mod+k'))
  open()
vue
<!-- 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.

Press to close

Props ​

PropTypeDefaultDescription
keysstring | string[][]'mod+k', or ['mod', 'k']
size'xs' | 'sm' | 'md''sm'
joinedbooleanfalseDraw a + between chips
ariaLabelstringthe spoken combinationOverrides the spoken name
unstyledboolean—Skip built-in classes
ui{ root?, key?, separator? }—Per-element class overrides

Slots ​

SlotPropsDescription
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.