Controls
Kbd
Keycaps on glass, singly or grouped.
Installation
pnpm dlx shadcn@latest add https://glasscn.app/r/kbd.jsonReact Native (iOS, Android and web through react-native-web) — same parts and props:
pnpm dlx shadcn@latest add https://glasscn.app/r/native-kbd.jsonOr with the namespace set up: shadcn add @glasscn-app/kbd
Source
components/glass/kbd.tsx
import * as React from "react"
import { cn } from "@/lib/glass-cn"
/** A keycap on glass. */
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-control-xs border border-glass-border bg-fill px-1 font-glass-sans text-xs font-medium text-muted-foreground select-none [&_svg:not([class*='size-'])]:size-3",
className
)}
{...props}
/>
)
}
/** Keys pressed together. A `<kbd>` (not a `<div>`), so it's valid inside a paragraph. */
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 }