Skip to content

Kbd

Data Display

Semantic keyboard-key hints for shortcuts and instructions.

Key combinationsNavigation keysSemantic keyboard markup
Open preview

Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.

Usage

Use Kbd for individual keys and combine keys in a visible shortcut hint. This component renders semantic kbd markup only; it does not register or intercept keyboard shortcuts.

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

Shipped as editable source in src/components/ui/kbd.tsx in both apps. Copy the implementation below when moving it to another project. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.

Component source

The complete implementation is included in both apps. It uses the React, Radix, Lucide, and shared-core dependencies already installed in Apex. Keep your project’s semantic theme tokens when reusing it.

src/components/ui/kbd.tsx
import type { ComponentProps } from "react";
import { cn } from "@dashboardpack/core/lib/utils";
export function Kbd({ className, ...props }: ComponentProps<"kbd">) {
  return (
    <kbd
      className={cn(
        "inline-flex min-h-6 min-w-6 items-center justify-center rounded-md border border-b-2 bg-muted px-1.5 font-mono text-[11px] font-medium text-muted-foreground",
        className,
      )}
      {...props}
    />
  );
}

API reference

Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.

Kbd props
PropType / DefaultDescription
childrenReactNode

Default: —

Key name or symbol.
classNamestring

Default: —

Extend the keycap style.
...propsHTML kbd attributes

Default: —

Standard element attributes.

Build with these too