Kbd
A keyboard key, as shown beside menu items.
Shortcuts
Press ⌘⇧S to save a copy.
import { Kbd } from "@applecn/ui/components/kbd"
import { Text } from "@applecn/ui/components/text"
export default function KbdBasic() {
return (
<Text className="flex items-center gap-2">
Press <Kbd>⌘</Kbd>
<Kbd>⇧</Kbd>
<Kbd>S</Kbd> to save a copy.
</Text>
)
}Install
From the registry this site publishes, with dependencies resolved by the CLI.
npx shadcn@latest add https://applecn.vercel.app/r/kbd.jsonSource
packages/ui/src/components/kbd.tsx
import { cn } from "cn"
import type { ComponentProps } from "react"
/** A keyboard key, as shown beside menu items and in help text. */
function Kbd({ className, ...props }: ComponentProps<"kbd">) {
return (
<kbd
data-slot="kbd"
className={cn(
"inline-flex h-5 min-w-5 items-center justify-center rounded-md bg-fill-3 px-1.5 type-caption-1 font-medium text-label-2",
className
)}
{...props}
/>
)
}
export { Kbd }