- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
- 手风琴
- 警报
- 警报对话框
- 纵横比
- 头像
- 徽章
- 面包屑
- 按钮
- 按钮组
- 日历
- 卡片
- 轮播
- 图表
- 复选框
- 可折叠
- 组合框
- 命令
- 上下文菜单
- 数据表格
- 日期选择器
- 对话框
- 方向
- 抽屉
- 下拉菜单
- 空
- 字段
- 悬停卡
- 输入
- 输入组
- 输入 OTP
- 条目
- 键盘
- 标签
- 菜单栏
- 原生选择
- 导航菜单
- 分页
- 弹出窗口
- 进度
- 单选按钮组
- 可调整大小
- 滚动区域
- 选择
- 分隔符
- 工作表
- 侧边栏
- 骨架
- 滑块
- Sonner
- 旋转器
- 切换
- 表格
- 标签
- 文本区域
- Toast
- 切换
- 切换组
- 工具提示
- 排版
import { Kbd, KbdGroup } from "@/components/ui/kbd"
export function KbdDemo() {安装
🌐 Installation
pnpm dlx shadcn@latest add kbd
用法
🌐 Usage
import { Kbd } from "@/components/ui/kbd"<Kbd>Ctrl</Kbd>示例
🌐 Examples
群组
🌐 Group
使用 KbdGroup 组件将键盘按键分组。
🌐 Use the KbdGroup component to group keyboard keys together.
Use Ctrl + BCtrl + K to open the command palette
import { Kbd, KbdGroup } from "@/components/ui/kbd"
export function KbdGroupExample() {按钮
🌐 Button
在 Button 组件内使用 Kbd 组件,在按钮内显示一个键盘按键。
🌐 Use the Kbd component inside a Button component to display a keyboard key inside a button.
import { Button } from "@/components/ui/button"
import { Kbd } from "@/components/ui/kbd"
工具提示
🌐 Tooltip
你可以在 Tooltip 组件内使用 Kbd 组件来显示带有键盘按键的工具提示。
🌐 You can use the Kbd component inside a Tooltip component to display a tooltip with a keyboard key.
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"
import { Kbd, KbdGroup } from "@/components/ui/kbd"输入组
🌐 Input Group
你可以在 InputGroupAddon 组件内使用 Kbd 组件来在输入组中显示一个键盘键。
🌐 You can use the Kbd component inside a InputGroupAddon component to display a keyboard key inside an input group.
import {
InputGroup,
InputGroupAddon,从右到左
🌐 RTL
要在 shadcn/ui 中启用 RTL 支持,请参阅 RTL 配置指南。
🌐 To enable RTL support in shadcn/ui, see the RTL configuration guide.
"use client"
import * as React from "react"API参考
🌐 API Reference
键盘
🌐 Kbd
使用 Kbd 组件显示一个键盘按键。
🌐 Use the Kbd component to display a keyboard key.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | `` |
<Kbd>Ctrl</Kbd>KbdGroup
使用 KbdGroup 组件将 Kbd 组件组合在一起。
🌐 Use the KbdGroup component to group Kbd components together.
| 属性 | 类型 | 默认值 |
|---|---|---|
className | string | `` |
<KbdGroup>
<Kbd>Ctrl</Kbd>
<Kbd>B</Kbd>
</KbdGroup>