Press Esc to close the panel.
A key in help text
import { Kbd, Text } from "@senvenli/react/display";
export default function Example() {
return (
<Text>
Press <Kbd>Esc</Kbd> to close the panel.
</Text>
);
}import { Kbd } from "@senvenli/react/display";Examples
A shortcut
`isModifier` shows ⌘ on Apple devices and Ctrl elsewhere.import { Kbd, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack direction="horizontal" space="space-100">
<Text>Search orders</Text>
<Stack direction="horizontal" space="space-050">
<Kbd isModifier />
<Kbd>K</Kbd>
</Stack>
</Stack>
);
}Glyph keys
A screen reader may skip a glyph, so `label` says the key's name.import { Kbd, Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
export default function Example() {
return (
<Stack direction="horizontal" space="space-100">
<Text>Add a line break</Text>
<Stack direction="horizontal" space="space-050">
<Kbd label="Shift">⇧</Kbd>
<Kbd label="Enter">↵</Kbd>
</Stack>
</Stack>
);
}Guidelines
When to use it
- Telling people which key or shortcut does something.
Accessibility
Built in
- Kbd isModifier shows ⌘ on Apple platforms and Ctrl elsewhere.
You provide
- A
labelfor glyph keys a screen reader may skip ("Command" for ⌘).
API reference
Kbd
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | – | One key per Kbd; a shortcut is several Kbd separated by a space. Left out with |
isModifier | boolean | – | The platform's shortcut modifier: ⌘ on Apple platforms, Ctrl elsewhere (Ctrl on the server, settled after mount). |
label | string | – | What a screen reader says instead of a glyph it may skip ("Command" for ⌘); the glyph is then hidden. |
childrenReact.ReactNodeOne key per Kbd; a shortcut is several Kbd separated by a space. Left out with
isModifier.isModifierbooleanThe platform's shortcut modifier: ⌘ on Apple platforms, Ctrl elsewhere (Ctrl on the server, settled after mount).
labelstringWhat a screen reader says instead of a glyph it may skip ("Command" for ⌘); the glyph is then hidden.