复制一段给 AI 编程工具的提示词,包含源码、依赖和用法
属性
CommandMenuProps
同时支持以下类型的全部属性: Omit<React.ComponentProps<"div">, "onSelect">
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| groups* 必填 | CommandGroup[] | — | — |
| placeholder | string | "Type a command or search…" | — |
| emptyText | string | "No results found." | — |
| onSelect | (item: CommandItem) => void | — | Called after an item's own onSelect |
| autoFocusSearch | boolean | false | Focus the search field on mount |
| showFooter | boolean | true | — |
CommandPaletteProps
同时支持以下类型的全部属性: CommandMenuProps
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| open* 必填 | boolean | — | — |
| onOpenChange* 必填 | (open: boolean) => void | — | — |
| hotkey | boolean | true | Toggle with ⌘K / Ctrl+K |
安装
$ npx shadcn@latest add https://chromotion.dev/r/command-palette.json命令行安装的是基础组件,定制的参数写在「定制」标签页生成的代码里。