Keyboard key
Shows a key or a shortcut, like Cmd K.
Add it to your project
With the shadcn/ui commandTerminal
npx shadcn@latest add kbd
First time with shadcn/ui? Set it up once.
The code
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 bg-muted px-1 font-sans text-xs font-medium text-muted-foreground select-none",
"[&_svg:not([class*='size-'])]:size-3",
"[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",
className
)}This comes with paid plans
The code for every component comes with paid plans, along with the rest of the AI toolkit. The first component under each heading is free.