SutraUI.Kbd (Sutra UI v0.3.0)
View SourceDisplays keyboard input that triggers an action.
The <kbd> element represents user input from a keyboard, voice input,
or any other text entry device. Commonly used to display keyboard shortcuts
or key combinations in documentation and user interfaces.
Examples
# Single key
<.kbd>Enter</.kbd>
# Key combination (render multiple kbd elements)
<.kbd>Ctrl</.kbd> + <.kbd>C</.kbd>
# With custom styling
<.kbd class="text-sm">Esc</.kbd>
# Common shortcuts
<.kbd>⌘</.kbd> + <.kbd>K</.kbd>Accessibility
- Uses the semantic
<kbd>HTML element which is recognized by screen readers - Screen readers will announce the content as keyboard input
- When displaying key combinations, use visible separators (like "+") between
individual
<kbd>elements for clarity - Consider providing additional context for complex shortcuts using
aria-labelon a parent container
Summary
Functions
Renders a keyboard key indicator.