Keyboard key
In code: Kbd
A key or a shortcut written in a sentence
Preview
Press ⌘K to search, N for a new booking and Esc to close.
Use
The code of the preview above
import { Kbd } from '@/components/ui';
<p>
Press <Kbd>⌘K</Kbd> to search, <Kbd>N</Kbd> for a new booking and <Kbd>Esc</Kbd> to close.
</p>Options
No options of its own.
It also takes the 280 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/card.csscomponents/stat.csscomponents/badge.csscomponents/alert.csscomponents/avatar.csscomponents/separator.csscomponents/loading.csscomponents/table.csscomponents/empty-state.csscomponents/tabs.csscomponents/resizable-panels.csscomponents/icons.csscomponents/chips.csscomponents/cells.csscomponents/inset.csscomponents/figure.csscomponents/avatar-group.csscomponents/hatch-bars.csscomponents/input-group.csscomponents/table-sorting-chosen-rows.csscomponents/tab-bar.csscomponents/prose.csscomponents/page-transitions.cssparts/avatar.cssparts/progress-meter.cssparts/carousel.cssparts/board.cssIn the examples
Small screens made with it and the rest of the kit. They work: click, type and choose in them.
Lately
Invoice 0412Kestrel StudioNovember
Helpers: states, do and don’t
A key or a shortcut written in a sentence: <Kbd>⌘K</Kbd>.
Hooks and functions the components are made of, passed on so a project uses the same ones: keyboard shortcuts, options loaded while typing, search matching, saved preferences, screen-reader announcements, smooth sizes, the theme.
Do
- Use
useShortcutfor app-wide keys, and show the key withformatShortcutso it reads right on each computer. - Use
announce()to tell a screen reader what changed when nothing visible takes focus ("3 results").
Don't
- Don't turn off the smooth sizes
Toasterstarts; boxes would jump when their content changes.