オーバーレイ
Command Palette
⌘K で開く、検索付きのコマンド一覧。入力で絞り込み、上下キーで移動して、Enter で実行します。
ReactVueWeb Components
Storybook で見る プレイグラウンド
使用例
const [open, setOpen] = useState(false);
<CommandPalette open={open} onOpenChange={setOpen} items={cmds} onSelect={run} /> 設定できる項目
| 名前 | 型 | 既定値 | 説明 |
|---|---|---|---|
open 必須 | boolean | — | Whether the palette is open. |
onOpenChange 必須 | (open: boolean) => void | — | Called to request open/close (Escape, backdrop, ⌘K). |
items 必須 | CommandItem[] | — | The commands. |
onSelect 必須 | (id: string) => void | — | Called with the chosen command id (the palette then closes). |
placeholder | string | コマンドを検索… | Search field placeholder. @default 'コマンドを検索…' |
emptyText | string | No results | Text when nothing matches. @default 'No results' |
hotkey | boolean | true | Register a global ⌘K / Ctrl+K toggle. @default true |
aria-label | string | Command palette | Accessible label for the dialog. @default 'Command palette' |
アクセシビリティ
- 文字と背景の明るさの差をしっかり取り、読みやすくしています。ライトでもダークでも、見やすさの国際基準 WCAG の最高ランク AAA(明るさの差が 7:1 以上)を満たします。
- マウスがなくても、キーボードだけですべての操作ができます。
- いまどこを操作しているかを示す枠(フォーカスの囲み)が、常にはっきり見えます。
- 利用者が「画面の動きを減らす」設定にしているときは、過剰なアニメーションを止めます。
どのコンポーネントも、だれにとっても使いやすいように、見やすさの国際基準 WCAG の最高ランク AAA(WCAG 2.1 AAA)を満たすよう作っています。