DesignOverviewDesign SystemMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingAgentsCortexMemoryActiveProvenanceActiveContextActiveServicesInsightsGet in touchSource on GitHub
Loading the reference
KbdView sourceEdit in SandboxView MarkdownCopy MarkdownOpen in ClaudeOpen in CursorA keyboard key or chord, set inline with text.Also called Key, Shortcut, and Hotkey.StableSince 0.1.0TypographyImportimport'@fusion.dev/helix/kbd'import'@fusion.dev/helix-headless/kbd'Preview
GuidelinesWhen to use
A key or a chord to press, written in a sentence, such as Ctrl+K to search.A shortcut that works the control it names, such as / to move to a search field.KbdThis page
Write a chord in keys, such as mod+k.It draws ⌘K on Apple devices and Ctrl+K elsewhere, and a ⌘K typed into a template is wrong on Windows.<helix-flexdirection="column"gap="md"><helix-textscale="body">
Press
<helix-kbdkeys="mod+k"></helix-kbd>
to search. The shortcut <helix-code>mod+k</helix-code> shows as ⌘K on a Mac and Ctrl+K on
other computers.
</helix-text><helix-inputaria-label="Filter"placeholder="Filter"><helix-kbdid="key"keys="/"slot="end"within="control"></helix-kbd></helix-input><helix-textemphasis="muted"id="said"scale="caption">
Click the field and press / to filter the list.
</helix-text></helix-flex><scripttype="module">constkey=document.getElementById('key')constsaid=document.getElementById('said')key.addEventListener('helix-shortcut',(event)=>{said.textContent=`Heard ${event.detail.keys} inside the field.`})</script><linkhref="styles.css"rel="stylesheet"/><divclass="stack"><p>
Press
<helix-headless-kbdkeys="mod+k"></helix-headless-kbd>
to search. The shortcut <code>mod+k</code> shows as ⌘K on a Mac and Ctrl+K on
other computers.
</p><helix-headless-inputaria-label="Filter"placeholder="Filter"><helix-headless-kbdid="key"keys="/"slot="end"within="control"></helix-headless-kbd></helix-headless-input><pclass="caption"id="said">
Click the field and press / to filter the list.
</p></div><scripttype="module">constkey=document.getElementById('key')constsaid=document.getElementById('said')key.addEventListener('helix-shortcut',(event)=>{said.textContent=`Heard ${event.detail.keys} inside the field.`})</script>
Write a sequence as one Kbd for each key, with the word between them as text, such as then.Each element holds one key, except under keys.
Set within for the shortcut to work.By default the key is drawn and listens for nothing.
API referenceRoothelix-kbdA keyboard key or chord, set inline with text.
PropTypeDescriptionactivate"click"|"focus"What the chord does to the control for names once it is pressed:
focus moves focus to the control and click presses it.capsbooleanDefaultfalseDraws a chord under keys as one key per key, each a key part with a
separator part between two where the platform writes a +, as GitHub
and most docs draw CtrlK.forstringDefault""The id of the control the shortcut works, which is given the chord as its
aria-keyshortcuts.keyLabelsRecord<string, string>Default{}Names for keys in place of the platform's own, by the key's name in
keys, written as JSON in the attribute: key-labels='{"mod":"Command", "enter":"Return"}' shows Command and Return wherever mod and
enter are written.keysstringDefault""The key or chord to show, such as mod+k, ?, or /.within"control"|"document"Where the chord is listened for. control listens inside the control the
key sits in, and document listens on the whole page.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The key's label, where keys is not set.
EventTypeDescriptionhelix-shortcutHelixShortcutEventThe chord was pressed. Cancelable: cancel it to let the key press keep its usual effect.
PartDescriptionkbdThe key, or the chord under keys.keyOne key of a chord under keys and caps, such as Ctrl in Ctrl+K.separatorThe + between two keys of a chord under keys and caps, drawn where the platform writes one: on Windows and Linux. An Apple keyboard writes none between glyphs, and a hyphen between words from key-labels.
CSS PropertyDescription--kbd-background-colorThe fill of the key.--kbd-block-sizeThe height of a key, and the least width of one, in em of the text around it.--kbd-border-colorThe color of the key's border and its bottom edge.--kbd-colorThe color of the key's label.--kbd-font-familyThe face of the key's label. Monospaced by default.--kbd-font-sizeThe size of the key's label, in em of the text around it.--kbd-font-weightThe weight of the key's label.--kbd-gapThe space between two keys of a chord under caps.--kbd-padding-inlineThe space either side of the key's label.--kbd-radiusHow far the key's corners are rounded.--kbd-separator-colorThe color of the + between two keys of a chord under caps.
Custom stateDescriptionsettledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Roothelix-headless-kbdA keyboard key or chord, set inline with text.
PropTypeDescriptionactivate"click"|"focus"What the chord does to the control for names once it is pressed:
focus moves focus to the control and click presses it.capsbooleanDefaultfalseDraws a chord under keys as one key per key, each a key part with a
separator part between two where the platform writes a +, as GitHub
and most docs draw CtrlK.forstringDefault""The id of the control the shortcut works, which is given the chord as its
aria-keyshortcuts.keyLabelsRecord<string, string>Default{}Names for keys in place of the platform's own, by the key's name in
keys, written as JSON in the attribute: key-labels='{"mod":"Command", "enter":"Return"}' shows Command and Return wherever mod and
enter are written.keysstringDefault""The key or chord to show, such as mod+k, ?, or /.within"control"|"document"Where the chord is listened for. control listens inside the control the
key sits in, and document listens on the whole page.
ReadTypeDescriptionwhenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.
SlotDescription(default)The key's label, where keys is not set.
EventTypeDescriptionhelix-shortcutHelixShortcutEventThe chord was pressed. Cancelable: cancel it to let the key press keep its usual effect.
PartDescriptionkbdThe key, or the chord under keys.keyOne key of a chord under keys and caps, such as Ctrl in Ctrl+K.separatorThe + between two keys of a chord under keys and caps, drawn where the platform writes one: on Windows and Linux. An Apple keyboard writes none between glyphs, and a hyphen between words from key-labels.
Custom stateDescriptionsettledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Examples
NameDescriptionCapsA chord drawn as a key per key with caps, so each key is a cap of its own.EventsA key that listens for its shortcut inside a field and sends helix-shortcut when it is pressed.PreviewA single key, and a chord of keys.PreviewA single key, and a chord of keys.ShortcutA chord written once as mod+k, shown as ⌘K on Apple keyboards and Ctrl+K on others.ShortcutA chord written once as mod+k, shown as ⌘K on Apple keyboards and Ctrl+K on others.