Typography

ShortcutHint

Inline shortcut hint that renders a key combo via Kbd alongside an action label, with an accessible text representation not reliant on visual keycaps alone.

import { ShortcutHint } from '@lostgradient/cinder';
shortcutinline
01

Overview

Reference usage

Inline shortcut hint that renders a key combo via Kbd alongside an action label, with an accessible text representation not reliant on visual keycaps alone.

Usage

svelte
<script lang="ts">
  import { ShortcutHint } from '@lostgradient/cinder';
</script>

<div style="display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap;">
  <ShortcutHint keys={['Ctrl', 'S']}>Save</ShortcutHint>
  <ShortcutHint keys={['Ctrl', 'Z']}>Undo</ShortcutHint>
  <ShortcutHint keys={['Escape']}>Cancel</ShortcutHint>
  <ShortcutHint keys={['Space']} keysLabel="Space bar" keysPosition="before">Play</ShortcutHint>
</div>

Guidance

Use When

  • Showing a keyboard shortcut inline beside a label in a toolbar button, menu item, or tooltip.
  • Pairing with command-palette items to surface available shortcuts.

Avoid When

  • Displaying a full shortcut reference table — use keyboard-shortcuts instead.

In a button

Prefer Button's shortcut prop to nesting a hint by hand. Inside a button on every variant the key caps drop their border, fill, and shadow and render as plain glyphs in the button's own text color, so the hint reads as part of the button in every theme. Touch devices hide it. Hand-written markup inside a button gets the same treatment.

Live preview

Toolbar shortcut hints

Save Ctrl plus S Undo Ctrl plus Z Cancel Escape Space bar Play

02

When to use

Use when
  • Showing a keyboard shortcut inline beside a label in a toolbar button, menu item, or tooltip.
  • Pairing with command-palette items to surface available shortcuts.
Avoid when
  • Displaying a full shortcut reference table — use keyboard-shortcuts instead.
03

Examples

Toolbar shortcut hints

Inline shortcut hints in a compact toolbar, keys positioned after the label.

04

Props

Props for shortcut-hint
Name
Type
Default
Description
keys required string[] The key sequence to display (e.g. ["Ctrl", "S"] or ["Space"]).
keysLabel text Optional accessible label for the key combo. Defaults to joining keys with " plus ".
children snippet The action or label to render alongside the key combo.
keysPosition 'before' | 'after' 'after' Whether to place the keys before or after the children.