Components
@shadcn/react
@shadcn/helpers
Utilities
⌘⇧⌥⌃Ctrl+B
import { Kbd, KbdGroup } from "@/components/ui/kbd"
export function KbdDemo() {安装#
pnpm dlx shadcn@latest add kbd
用法#
import { Kbd } from "@/components/ui/kbd"<Kbd>Ctrl</Kbd>组合#
使用以下组合来构建 Kbd 和 KbdGroup:
Kbd
KbdGroup
├── Kbd
└── Kbd组合#
使用 KbdGroup 组件将键盘按键组合在一起。
Use Ctrl + BCtrl + K to open the command palette
import { Kbd, KbdGroup } from "@/components/ui/kbd"
export function KbdGroupExample() {按钮#
在 Button 组件中使用 Kbd 组件,以在按钮内显示键盘按键。
import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
工具提示#
你可以在 Tooltip 组件中使用 Kbd 组件,以显示带有键盘按键的工具提示。
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { Kbd, KbdGroup } from "@/components/ui/kbd"输入组#
您可以在 InputGroupAddon 组件中使用 Kbd 组件,以在输入组内显示键盘按键。
⌘K
import { SearchIcon } from "lucide-react"
import {RTL#
要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南。
⌘⇧⌥⌃Ctrl+B
"use client"
import * as React from "react"API 参考#
Kbd#
使用 Kbd 组件显示键盘按键。
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | `` |
<Kbd>Ctrl</Kbd>KbdGroup#
使用 KbdGroup 组件将多个 Kbd 组件组合在一起。
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | `` |
<KbdGroup>
<Kbd>Ctrl</Kbd>
<Kbd>B</Kbd>
</KbdGroup>