Kbd
Kbd is a decorative element used to represent specific keyboard keys. It is typically embedded inside components (e.g., menu, table, button) or paragraph text, to communicate an associated keyboard shortcut or a user instruction.
Also known as: Key
| Salt package | @salt-ds/core |
|---|---|
| Available since | 1.58.0 |
- To display keyboard shortcuts: Use Kbd to visually highlight keyboard keys or combinations (e.g., "Ctrl + S") in documentation.
- Inline with instructions: When providing step-by-step instructions or help text that references keyboard actions.
- In inputs: To show associated shortcuts for actions, such as “Save (Ctrl + S)” in a button or “Press Enter” in an input field.
- In a menu: To associate with actions, such as the macOS Menu Bar or MS Taskbar.
- To improve accessibility: When you want users to easily identify and understand available keyboard shortcuts.
- For power users: Especially beneficial for users who are familiar with the application and frequently perform tasks at speed.
- For non-keyboard actions: Don't use Kbd to represent mouse actions, gestures, or other non-keyboard interactions.
- For non-keyboard or decorative use: Don't use Kbd for purely decorative or stylistic purposes that are unrelated to actual keyboard input.
- For long text or sentences: Kbd is not suitable for wrapping entire sentences or paragraphs—use it only for individual keys or short key combinations.
To import Kbd from the Salt core package, use:
import { Kbd } from "@salt-ds/core";