Start here
  • InstallationAdd Nelumbo to a shadcn project
  • ThemingBrand accent, neutrals, dynamic color
  • Biology componentsSequences, maps, plates and trees
  • katalyx.bio

    Kbd

    A keycap for showing a key or a shortcut: a small raised key with a darker lower edge. It is the same cap Command and the menus use for their shortcuts, so a shortcut looks the same everywhere.

    Install

    npx shadcn@latest add @nelumbo/kbd

    Keys and groups

    Kbd is one key. KbdGroup sets several side by side with a small gap.

    Esc⌘Enter⌘⇧PCtrlK

    Shortcut strings

    KbdShortcut turns a string into separate caps: "⌘⇧P", "⌘ K" or "Ctrl+Shift+K". Screen readers hear the whole string once, not each key.

    ⌘⇧PCtrl+Shift+K⌥⌘BEsc

    In text and buttons

    Keycaps sit on the text baseline's center, so they work inline and inside a button.

    Press / to focus the search, or ⌘K to open the command palette.

    On dark surfaces

    Inside a tooltip (hover or focus the button) the cap switches to the inverse look and gets smaller by itself. Anywhere else on a dark surface, use variant="inverse": it is a translucent tint of the text color, so it works on black and on white.

    Undo⌘Z

    Props

    PropTypeDefaultNotes
    Kbd variant"default" | "inverse""default"Inverse tints the key with the text color, for dark surfaces.
    Kbd ...propsComponentProps<'kbd'>Rendered as a <kbd> with data-slot=kbd.
    KbdGroup ...propsComponentProps<'span'>Inline-flex row with a 4px gap.
    KbdShortcut childrenstringA shortcut such as ⌘⇧P or Ctrl+Shift+K. Anything else is drawn as one cap.
    KbdShortcut variant"default" | "inverse""default"Passed to every key.
    splitKeys(shortcut)(string) => string[]The parser behind KbdShortcut.