Getting Started
Components52
- Accordion
- Alert
- Alert Dialog
- Attachment
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Collapsible
- Command
- Context Menu
- Data Table
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Pagination
- Popover
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
EscK⌘KCtrlthenB
import { CommandIcon } from "lucide-react"
import { Kbd, KbdGroup } from "@/components/ui/kbd"
export function KbdDemo() {
return (
<div className="flex flex-wrap items-center gap-2">
<Kbd>Esc</Kbd>
<Kbd>K</Kbd>
<Kbd>
<CommandIcon />
</Kbd>
<KbdGroup>
<Kbd>⌘</Kbd>
<Kbd>K</Kbd>
</KbdGroup>
<KbdGroup>
<Kbd>Ctrl</Kbd>
<span className="text-xs text-muted-foreground">then</span>
<Kbd>B</Kbd>
</KbdGroup>
</div>
)
}Installation#
pnpm dlx shadcn@latest add https://ui.ikramhasan.com/r/kbd.json
Usage#
import { Kbd } from "@/components/ui/kbd"<Kbd>Ctrl</Kbd>Examples#
Quick actions#
⌘K
import { SearchIcon } from "lucide-react"
import {
InputGroup,
InputGroupAddon,
InputGroupInput,
} from "@/components/ui/input-group"
import { Kbd } from "@/components/ui/kbd"
export function KbdQuickActions() {
return (
<InputGroup className="max-w-xs">
<InputGroupInput placeholder="Quick actions" aria-label="Quick actions" />
<InputGroupAddon>
<SearchIcon />
</InputGroupAddon>
<InputGroupAddon align="inline-end">
<Kbd>⌘K</Kbd>
</InputGroupAddon>
</InputGroup>
)
}In text and buttons#
Press ⌘ / to see every shortcut.
import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
export function KbdInTextAndButtons() {
return (
<div className="flex flex-wrap items-center gap-2">
<p className="text-muted-foreground">
Press <Kbd>⌘</Kbd> <Kbd>/</Kbd> to see every shortcut.
</p>
<Button variant="secondary">
Search
<Kbd data-icon="inline-end">⌘K</Kbd>
</Button>
</div>
)
}API Reference#
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>