React Native · Components
Kbd
A keyboard key or shortcut (the same notation as web).
3 exports
Live example
The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.
Preview
Press Control+Shift+P to open commands.
Code
Events
- Events appear here when you interact with the preview.
Key sequence and hand-written key
Go to dashboard: G, DSend: Control+EnterEsc
Import
Kbd
componentA keyboard key or shortcut (the same notation as web). Shows shortcuts in apps used with tablets and external keyboards, and keys on help screens.
- The shortcut is given with
keys; "⌘K" on iOS/iPadOS, "Ctrl+K" on Android. - Screen readers read key names, not symbols ("Meta+K").
- Bound to the appearance system (
appearance.defaults.kbd, custom variants).
Examples
KbdVariant
typeLook of the key box (same as web).
outline: bordered with a thick bottom edge; looks like a real key.soft: borderless with a muted background; plain in menus and tooltips.ghost: text only; inside buttons.
KbdProps
interfaceProps of the Kbd component.
| Name | Type | Default | Description |
|---|---|---|---|
ref? | Ref<ViewRef> | Reference to the root view. | |
keys? | string | Shortcut to show: "Mod+K", "Mod+Shift+P", "Alt+Enter", "Esc". Mod is written as ⌘ on iOS/iPadOS and Ctrl on Android. Separate key sequences (e.g. G then D) with a space: "G D". If omitted children is shown as is. | |
children? | ReactNode | Hand-written content instead of keys (e.g. "Enter"). | |
split? | boolean | false | Show each key in its own box? With false the whole shortcut is in one box (e.g. "⇧⌘P" or "Ctrl+Shift+P"). |
variant? | KbdVariant | (string & {}) | "outline" | Variant: a built-in one (KbdVariant) or a custom variant added with defineAppearance. Defaults to UIProvider appearance.defaults.kbd.variant. |
size? | "sm" | "md" | "md" | Size. |
apple? | boolean | Whether the shortcut is written in Apple style (⌘, ⇧). Defaults to true on iOS/iPadOS and false on Android. | |
style? | StyleProp<ViewStyle> | Root style. | |
testID? | string | Test id. |