adit-firdaus

Kbd

Component

About

A keyboard key cap for displaying shortcuts, with named modifier glyphs (⌘ ⇧ ⌥ ⌃) and an optional live mode that lights up while the matching physical key is actually held down.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Kbd to your project and fits it to your theme.

Code

How Kbd is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { Kbd } from "@/components/ui/kbd";

function Combo({ keys }: { keys: string[] }) {
  return (
    <span
      style={{ display: "inline-flex", gap: "0.25rem", alignItems: "center" }}
    >
      {keys.map((key) => (
        <Kbd key={key}>{key}</Kbd>
      ))}
    </span>
  );
}

function MenuItem({ title, keys }: { title: string; keys: string[] }) {
  return (
    <div
      style={{
        display: "flex",
        alignItems: "center",
        justifyContent: "space-between",
        gap: "1.5rem",
        minHeight: "2.25rem",
        padding: "0 0.75rem",
      }}
    >
      <span
        style={{
          fontSize: "var(--may-text-subheadline)",
          color: "var(--may-color-text)",
        }}
      >
        {title}
      </span>
      <Combo keys={keys} />
    </div>
  );
}

export default function KbdMenuDemo() {
  return (
    <div className="flex min-h-[200px] w-full items-center justify-center bg-background p-10 text-foreground">
      <div
        style={{
          maxWidth: 320,
          width: "100%",
          padding: "0.5rem",
          borderRadius: "var(--may-radius-card)",
          background: "var(--may-color-surface)",
          boxShadow: "var(--may-shadow-md)",
          display: "flex",
          flexDirection: "column",
        }}
      >
        <MenuItem title="New Message" keys={["cmd", "N"]} />
        <MenuItem title="Reply All" keys={["shift", "cmd", "R"]} />
        <MenuItem title="Move to Junk" keys={["shift", "cmd", "J"]} />
        <MenuItem title="Delete" keys={["delete"]} />
      </div>
    </div>
  );
}

More by adit-firdaus

View all
  • Steps

    Steps

    36
  • Popover

    Popover

    3
  • Adaptive Card

    Adaptive Card

  • Box

    Box

  • Pagination

    Pagination

  • Adaptive Sheet

    Adaptive Sheet

  • Notice Bar

    Notice Bar

  • Label

    Label