DisplayNew
Kbd
Shows a keyboard key or shortcut.
LiveRev. 01
⌘⇧P
Press ⌘ K to search, or Esc to close.
Installation
CLI
$ npx shadcn@latest add https://konsa.rohitxyz.me/r/kbd.jsonManual
Copy the source into your project
components/ui/kbd.tsx
import * as React from "react";
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 min-w-5 items-center justify-center gap-1 rounded-[4px] border border-b-2 bg-muted px-1 font-sans text-[11px] font-medium text-muted-foreground select-none [&_svg]:size-3",
className,
)}
{...props}
/>
);
}
function KbdGroup({ className, ...props }: React.ComponentProps<"span">) {
return (
<span
data-slot="kbd-group"
className={cn("inline-flex items-center gap-1", className)}
{...props}
/>
);
}
export { Kbd, KbdGroup };Update the import paths to match your project
The file imports cn from @/lib/utils. See installation.
Usage
import { Kbd, KbdGroup } from "@/components/ui/kbd";<KbdGroup>
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
</KbdGroup>