Kbd
A keyboard key.
Press ⌘ K to search the docs.
Install
$ npx shadcn@latest add @nudgekit/kbdOr with no config: npx shadcn@latest add https://ui.nudgekit.app/r/kbd.json
Usage
usage.tsx
import { Kbd } from "@/components/ui/kbd"
Press <Kbd>⌘</Kbd> <Kbd>K</Kbd> to search.Do
- Use one Kbd per key.
Don't
- Use it for anything that is not a key.
Code
What the CLI writes into your project. It is yours to change.
components/ui/kbd.tsx
import * as React from "react";
import { cn } from "@/lib/utils";
function Kbd({ className, ...props }: React.HTMLAttributes<HTMLElement>) {
return (
<kbd
data-slot="kbd"
className={cn(
"inline-flex h-6 min-w-6 items-center justify-center rounded-[5px] border border-border border-b-line-strong bg-surface px-1.5 font-mono text-[11px] font-medium text-muted-foreground",
className,
)}
{...props}
/>
);
}
export { Kbd };