Kbd
Display keyboard shortcuts and key combinations
Usage
import { Kbd } from "@lenso/ui";"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function Basic() { return ( <div {...stylex.props(s.row4)}> <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>K</Kbd.Content> </Kbd> <Kbd> <Kbd.Abbr keyValue="shift" /> <Kbd.Content>P</Kbd.Content> </Kbd> <Kbd> <Kbd.Abbr keyValue="ctrl" /> <Kbd.Content>C</Kbd.Content> </Kbd> <Kbd> <Kbd.Abbr keyValue="option" /> <Kbd.Content>D</Kbd.Content> </Kbd> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Anatomy
import { Kbd } from "@lenso/ui";
export default () => ( <Kbd> <Kbd.Abbr title="Command">⌘</Kbd.Abbr> <Kbd.Content>K</Kbd.Content> </Kbd>);Examples
Variants
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function Variants() { return ( <div {...stylex.props(s.column4)}> {[ { label: "Copy:", key: "C" }, { label: "Paste:", key: "V" }, { label: "Cut:", key: "X" }, ].map((action) => ( <div key={action.key} {...stylex.props(s.row2)}> <span>{action.label}</span> <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>{action.key}</Kbd.Content> </Kbd> <Kbd variant="light"> <Kbd.Abbr keyValue="command" /> <Kbd.Content>{action.key}</Kbd.Content> </Kbd> </div> ))} </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Navigation Keys
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function NavigationKeys() { return ( <div {...stylex.props(s.column4)}> <div {...stylex.props(s.row2)}> <span {...stylex.props(s.textSm, s.muted)}>Arrow Keys:</span> <div {...stylex.props(s.row2)}> <Kbd> <Kbd.Abbr keyValue="up" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="down" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="left" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="right" /> </Kbd> </div> </div> <div {...stylex.props(s.row2)}> <span {...stylex.props(s.textSm, s.muted)}>Page Navigation:</span> <div {...stylex.props(s.row2)}> <Kbd> <Kbd.Abbr keyValue="pageup" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="pagedown" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="home" /> </Kbd> <Kbd> <Kbd.Abbr keyValue="end" /> </Kbd> </div> </div> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Inline Usage
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function InlineUsage() { return ( <div> <p {...stylex.props(s.textSm)}> Press{" "} <Kbd> <Kbd.Content>Esc</Kbd.Content> </Kbd>{" "} to close the dialog. </p> <p {...stylex.props(s.textSm, s.space4)}> Use{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>K</Kbd.Content> </Kbd>{" "} to open the command palette. </p> <p {...stylex.props(s.textSm, s.space4)}> Navigate with{" "} <Kbd> <Kbd.Abbr keyValue="up" /> </Kbd>{" "} and{" "} <Kbd> <Kbd.Abbr keyValue="down" /> </Kbd>{" "} arrow keys. </p> <p {...stylex.props(s.textSm, s.space4)}> Save your work with{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>S</Kbd.Content> </Kbd>{" "} regularly. </p> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Instructional Text
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function InstructionalText() { return ( <div> <div {...stylex.props(s.kbdPanel)}> <h4 {...stylex.props(s.kbdHeading)}>Quick Actions</h4> <ul {...stylex.props(s.textSm)}> <li> • Open search:{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>K</Kbd.Content> </Kbd> </li> <li {...stylex.props(s.space2)}> • Toggle sidebar:{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>B</Kbd.Content> </Kbd> </li> <li {...stylex.props(s.space2)}> • New file:{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>N</Kbd.Content> </Kbd> </li> <li {...stylex.props(s.space2)}> • Quick save:{" "} <Kbd> <Kbd.Abbr keyValue="command" /> <Kbd.Content>S</Kbd.Content> </Kbd> </li> </ul> </div> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Special Keys
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function SpecialKeys() { return ( <div> <p {...stylex.props(s.textSm)}> Press{" "} <Kbd> <Kbd.Abbr keyValue="enter" /> </Kbd>{" "} to confirm or{" "} <Kbd> <Kbd.Abbr keyValue="escape" /> </Kbd>{" "} to cancel. </p> <p {...stylex.props(s.textSm, s.space3)}> Use{" "} <Kbd> <Kbd.Abbr keyValue="tab" /> </Kbd>{" "} to navigate between form fields and{" "} <Kbd> <Kbd.Abbr keyValue="shift" /> <Kbd.Abbr keyValue="tab" /> </Kbd>{" "} to go back. </p> <p {...stylex.props(s.textSm, s.space3)}> Hold{" "} <Kbd> <Kbd.Abbr keyValue="space" /> </Kbd>{" "} to temporarily enable panning mode. </p> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Customization
Tailwind CSS
"use client";// Adapted from HeroUI v3.2.6 (e385ac202b2cdb94b1bf6fa76d32c31c8259cc5e), Apache-2.0.import { Kbd } from "@lenso/ui";import * as stylex from "@stylexjs/stylex";import { s } from "../card/display.stylex";
export function CustomStyles() { return ( <div {...stylex.props(s.row3)}> <Kbd xstyle={s.kbdAccent}> <Kbd.Abbr keyValue="command" /> <Kbd.Content>K</Kbd.Content> </Kbd> <Kbd xstyle={s.kbdDefault}> <Kbd.Abbr keyValue="shift" /> <Kbd.Content>P</Kbd.Content> </Kbd> </div> );}Local adaptation source above. Derived from HeroUI v3.2.6 source.
Global CSS
To customize the Kbd component classes, you can use the @layer components directive.
Learn more.
@layer components { .kbd { @apply bg-gray-100 dark:bg-gray-800 border-gray-300; }
.kbd__abbr { @apply font-bold; }
.kbd__content { @apply text-sm; }}Styling Reference
HeroUI follows the BEM methodology to ensure component variants and states are reusable and easy to customize.
CSS Classes
The Kbd component uses these CSS classes (View source styles):
Base Classes [!toc]
.kbd- Base keyboard key styles with background, border, and spacing.kbd__abbr- Abbreviation element for modifier keys.kbd__content- Content wrapper for key text
API Reference
Kbd
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Content of the key |
variant | `"default" | "light"` | default |
className | string | - | Custom CSS classes |
Kbd.Abbr
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | - | Title attribute for accessibility (e.g., "Command" for ⌘) |
children | React.ReactNode | - | The symbol or text to display (e.g., ⌘, ⌥, ⇧) |
className | string | - | Custom CSS classes |
Kbd.Key
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNode | - | Text content of the key |
className | string | - | Custom CSS classes |
Kbd.Content Type
Available key values for the keyValue prop:
| Modifier Keys | Special Keys | Navigation Keys | Function Keys |
|---|---|---|---|
command | enter | up | fn |
shift | delete | down | |
ctrl | escape | left | |
option | tab | right | |
alt | space | pageup | |
win | capslock | pagedown | |
help | home | ||
end |