Kbd
A key or a shortcut, drawn as keys that fit the text around them. Mod is ⌘ on a Mac and Ctrl elsewhere, and each key sinks while it is held.
Examples
Default
One key, or a KbdGroup of keys pressed together. Write Mod for ⌘ on a Mac and Ctrl elsewhere; modifiers are drawn and ordered the platform’s way, so this Redo reads ⇧⌘Z on a Mac and Ctrl Shift Z elsewhere. Hold a key to see it sink.
Press Question mark to see every shortcut.
Press CtrlK to open the command menu from anywhere.
Esc closes it
In text
A key is sized in em and takes the colour of the text around it, so it fits small print, a paragraph and a heading alike.
In a field, a button, a tooltip and a menu
Keys answer the shortcuts they show: press / to search or Mod S to save. Put aria-keyshortcuts on the control the shortcut runs.
- Invoices: KN-482 Recalculate totals on rate change
- Invite members to Billing
Icons
An icon as the label needs name, the key as KeyboardEvent.key names it, so the key knows when it is held and what a screen reader should say.
Installation
npx shadcn@latest add https://kinoui.com/r/kbd.json- Files
lib/keys.tsxlib/reduce-motion.tscomponents/kino/kbd.tsx- Global CSS
- the feels, the density tokens, the shape tokens and the success and warning colours
New to Kino? Installation covers what your project needs first and the @kino namespace.
API reference
Kbd
Data attributes
CSS variables
Accessibility
- A key whose label is a symbol (⌘, ⇧, ↵, /) hides the symbol from screen readers and reads words in its place, such as “Command K”, since screen readers speak symbols unevenly and ignore a name on a
<kbd>. - A hint doesn’t run its shortcut. Put
aria-keyshortcutson the control the shortcut runs, so a screen reader announces it there. - A held key sinks and its edge flattens; in forced colours it takes the system’s highlight.
- Write words such as “then” and “or” outside the keys, so they aren’t read as keys.