KBD
Displays keyboard keys and shortcuts.
KbdExample
⌘KShift
Examples
Group
Group multiple keys together to represent keyboard shortcuts.
KbdGroupExample
⌘+KCtrl+Shift+B
Installation
Copy the source code below into your project:
import { cn } from "@/lib/utils";
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
return (
<kbd
data-slot="kbd"
className={cn(
"pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm border border-border bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none",
"group-data-highlighted:border-primary-foreground/30 group-data-highlighted:bg-primary-foreground/20 group-data-highlighted:text-primary-foreground",
"[&_svg:not([class*='size-'])]:size-3",
className,
)}
{...props}
/>
);
}
function KbdGroup({ className, ...props }: React.ComponentProps<"kbd">) {
return (
<kbd
data-slot="kbd-group"
className={cn("inline-flex items-center gap-1", className)}
{...props}
/>
);
}
export { Kbd, KbdGroup };API Reference
The Kbd component extends the HTML kbd element props and adds the following:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional CSS classes to apply to the keyboard key. |
The KbdGroup component extends the HTML kbd element props and adds the following:
| Prop | Type | Default | Description |
|---|---|---|---|
| className | string | - | Additional CSS classes to apply to the keyboard key group. |