Components
Kbd
Used to display textual user input from keyboard.
Loading...
Installation
CLI
npx shadcn@latest add https://exawizards.com/exabase/design/registry/kbd.jsonManual
Copy and paste the following code into your project.
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",
className
)}
{...props}
/>
)
}
function KbdGroup({ className, ...props }: React.ComponentProps<"div">) {
return (
<kbd
data-slot="kbd-group"
className={cn("inline-flex items-center gap-1", className)}
{...props}
/>
)
}
export { Kbd, KbdGroup }
Usage
import { Kbd } from "@/components/ui/kbd"<Kbd>Ctrl</Kbd>Examples
Group
Use the KbdGroup component to group keyboard keys together.
Loading...
Button
Use the Kbd component inside a Button component to display a keyboard key inside a button.
Loading...
Tooltip
You can use the Kbd component inside a Tooltip component to display a tooltip with a keyboard key.
Loading...
Input Group
You can use the Kbd component inside a InputGroupAddon component to display a keyboard key inside an input group.
Loading...
API
Kbd
Use the Kbd component to display a keyboard key.
| Prop | Type | Default |
|---|---|---|
className | string | `` |
<Kbd>Ctrl</Kbd>KbdGroup
Use the KbdGroup component to group Kbd components together.
| Prop | Type | Default |
|---|---|---|
className | string | `` |
<KbdGroup>
<Kbd>Ctrl</Kbd>
<Kbd>B</Kbd>
</KbdGroup>