Kbd
Kbd shows a key or a keyboard shortcut, such as ⌘K.
Use a Kbd to show a key or a shortcut that a person presses. For code, such as a command or a file name, use Code. For a short label or a status, use Chip. In a Menu, put a Kbd in a row's trailing slot to show that row's shortcut.
A Kbd looks like a small key cap, with a subtle fill, a grey border and a slight raised shadow. It uses the body font rather than a code font, so symbols such as ⌘ draw at their normal size. It is exactly one line tall, so it never pushes apart the lines of text around it.
Without size, a key matches the size of the text around it, so set size only when the key stands alone. tone changes the colour of the letters and the fill, and the border stays grey.
A Kbd renders a <kbd> element, which tells a screen reader that the text is keyboard input.
Props
Generated from the types. It lists what this component DECLARES: a prop that arrives from a shared type or from the platform is real and is not repeated here.
| Prop | Type | What it does |
|---|---|---|
className? | string | Your classes, appended to the ones this component resolves rather than replacing them. |
emphasis? | "loud" | "medium" | "quiet" | The emphasis level of the text: loud, medium or quiet. |
render? | RenderElement | Renders the key as a different element. |
size? | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | The text size step, from 1 to 9. |
style? | React.CSSProperties | Inline styles, merged last, so your value wins over anything the component resolved. |
tone? | "neutral" | "accent" | "destructive" | "blue" | "green" | "orange" | "amber" | "pink" | "purple" | "success" | "warning" | "info" | The colour family of the text and the fill. |
weight? | "regular" | "medium" | "semibold" | The font weight, by name. |
It also takes every prop of a <kbd>.