Kbd

Keyboard keys and shortcuts such as ⌘K.

Search
Command K
Create an issue
C
Go to inbox
GthenI
Send a reply
Command Return
Command menu
Command Shift P

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/kbd

Usage

import { Kbd } from "./ui/uicontext/components/Kbd.ts"
export const SearchHint = <M>(h: Html.H<M>) => h.p.children("Press ", Kbd(h, "mod+k", { size: "sm" }), " to search.")

Examples

Mac and other platforms

The same keys as ⌘⇧P or Ctrl Shift P. Screen readers hear “Command Shift P”.

MacCommand Shift P
Windows and LinuxControl Shift P

API reference

Options

Kbd options
NameTypeDefaultDescription
size"sm" | "md"mdThe keycap's size; md by default.
tone"default" | "inherit"—"inherit" takes the color of what it sits on, for a keycap inside a button
macbooleantrue⌘ ⌥ ⇧ on a Mac, Ctrl Alt Shift elsewhere; true by default
styleStyle—StyleX styles applied after the keycap’s own.

Accessibility

  • A combination is a <kbd> of <kbd>s. The caps show symbols, and screen readers hear words instead: "Command K", never "⌘ K".
  • mod shows ⌘ on a Mac and Ctrl elsewhere, and is spoken to match.

Source