Shortcut recorder
Record key combinations into key caps, with conflict warnings, Kbd, and a searchable cheatsheet.
npx shadcn@latest add @silicon-ui/shortcut-recorderInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/shortcut-recorderManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/shortcut-recorder/shortcut-recorder.tsx
- components/silicon-ui/shortcut-recorder/shortcut-recorder.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
ShortcutRecorder
| Prop | Type | Default |
|---|---|---|
label* | string | — |
hideLabel | boolean | false |
value | string | null | — |
defaultValue | string | null | null |
onValueChange`replaced` is the binding the new shortcut was taken from after "Use anyway", so the caller can unbind it. | (value: string | null, details: { replaced?: ShortcutBinding }) => void | — |
resetValueWhat the reset button restores. Defaults to `defaultValue`. | string | null | — |
bindingsShortcuts already in use. Recording one of them asks before taking it. | ShortcutBinding[] | [] |
warnReservedAlso warn about combinations the browser or system keeps, such as ⌘W and ⌘C. On by default. | boolean | true |
requireModifierRequire ⌘, Ctrl, or ⌥ (function keys are always allowed). On by default. | boolean | true |
platform | Platform
| — |
placeholder | string | "Record shortcut" |
description | string | — |
disabled | boolean | false |
id | string | — |
className | string | — |
ShortcutKeys
| Prop | Type | Default |
|---|---|---|
shortcut* | string | — |
platform | Platform
| — |
pressedHeld key ids from `usePressedKeys`; matching caps light up. | ReadonlySet<string> | — |
size | "sm" | "md" | "md" |
className | string | — |
ShortcutList
| Prop | Type | Default |
|---|---|---|
groups* | ShortcutListGroup[] | — |
labelAccessible name of the list. | string | "Keyboard shortcuts" |
searchable | boolean | true |
searchPlaceholder | string | "Search shortcuts" |
highlightPressedLight up caps as keys are held, and fade rows that do not use the held modifiers. On by default. | boolean | true |
platform | Platform
| — |
className | string | — |
ShortcutKbd
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | — |
pressedDraws the key pushed down and lit, such as while it is held. | boolean | false |
size | "sm" | "md" | "md" |
Also accepts the props of HTMLAttributes<HTMLElement>.
Kbd
| Prop | Type | Default |
|---|---|---|
children* | ReactNode | — |
pressedDraws the key pushed down and lit, such as while it is held. | boolean | — |
size | "sm" | "md" | — |
Also accepts the props of HTMLAttributes.
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens