KeyboardShortcutDialog 键盘快捷键对话框
反馈组件
键盘快捷键对话框 — Chaos UI 的反馈组件。
何时使用
需要键盘快捷键对话框功能时使用本组件。
代码示例
基础用法
tsx
import { KeyboardShortcutDialog } from "@chaos_team/chaos-ui/ui"
export function Basic() {
return <KeyboardShortcutDialog open={true} onClose={() => {}} groups={[]} />
}}`} lang="tsx" />
尺寸
tsx
{/* 尺寸对照 */}
<div className="flex flex-wrap items-center gap-3">
<KeyboardShortcutDialog size="sm">Sm</KeyboardShortcutDialog>
<KeyboardShortcutDialog size="default">Default</KeyboardShortcutDialog>
<KeyboardShortcutDialog size="lg">Lg</KeyboardShortcutDialog>
</div>样式变体
尺寸
| Size | 说明 | 默认 |
|---|---|---|
default | 默认尺寸 | ✓ |
sm | 小号 | |
lg | 大号 |
API / Props
KeyboardShortcutDialog
| Prop | Type | Default | 说明 |
|---|---|---|---|
className | string | — | 自定义样式类名 |
open | boolean | false | Whether the dialog is open |
onClose | () => void | — | Called when the dialog should close |
groups | ShortcutGroup[] | — | Shortcut groups to display |
| ...rest | React.ComponentProps<"div"> | — | 透传 <div> 原生属性 |
注意事项
- Client Component: 使用
"use client",依赖 React hooks/状态,需在客户端渲染。 - CVA 变体: 通过
class-variance-authority管理样式变体,类型安全。变体对象可导出复用。 - 原生属性: 继承所有
<div>原生 HTML 属性。
📘 完整交互式示例与控件属性请查看 Storybook 文档。