命令面板
查找并执行操作。
用法
通过明确的触发器或可选的 Mod+K 快捷键打开,传入带描述的分组结果和所需的搜索过滤器。
无障碍
使用方向键、Enter 和 Escape。提供清晰的结果名称与描述。
| 属性 | 类型 | 默认值 |
|---|---|---|
| items | readonly CommandPaletteItem[] | Required |
| open / defaultOpen | boolean | false |
| onOpenChange | (open: boolean) => void | None |
| shortcut | boolean | false |
| dismissLabel | string | None |
| maxResults | number | All |
| filter | (item, query) => boolean | Default matching |
<CommandPalette
trigger={<Button>Commands</Button>}
title="Commands"
description="Choose an action"
searchLabel="Search commands"
emptyLabel="No commands found"
dismissLabel="Close commands"
items={[
{ id: 'save', label: 'Save project', group: 'Project', description: 'Save current changes', onSelect: () => {} },
{ id: 'guide', label: 'Usage guide', group: 'Documentation', onSelect: () => {} },
]}
/>