Command
コマンドパレット風の検索・選択コンポーネント。
インポート
個別サブパス(バンドルサイズを抑えたい場合):
基本的な使い方
Commandは単体でもインライン表示できます(cmdkベースの検索付きリスト)。
Loading...
コマンドパレット(CommandDialog)
CommandDialogはDialogをベースにしたコマンドパレットです。⌘Kのようなショートカットで
開閉するUIによく使われます。ショートカットの表示にはCommandShortcutを使います。
Loading...
Props
Command
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | 追加のCSSクラス |
cmdkのCommand(Root)のpropsをそのまま受け取ります(loop、filter、shouldFilterなど)。
CommandDialog
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | - | 開閉状態(制御コンポーネント) |
onOpenChange | (open: boolean) => void | - | 開閉変更時のコールバック |
title | string | 'Command Palette' | アクセシビリティ用タイトル(sr-onlyで非表示表示) |
description | string | 'Search for a command to run...' | アクセシビリティ用説明文(sr-onlyで非表示表示) |
showCloseButton | boolean | false | 右上の閉じるボタンを表示するか |
className | string | - | 追加のCSSクラス |
CommandInput
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | - | 検索入力欄のプレースホルダー |
value | string | - | 検索文字列(制御コンポーネント) |
onValueChange | (value: string) => void | - | 検索文字列変更時のコールバック |
CommandList
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | 追加のCSSクラス(最大高さは`max-h-[300px]`で内部スクロール) |
CommandEmpty
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | 検索結果が0件のときに表示するコンテンツ |
CommandGroup
| Prop | Type | Default | Description |
|---|---|---|---|
heading | ReactNode | - | グループの見出し |
className | string | - | 追加のCSSクラス |
CommandItem
| Prop | Type | Default | Description |
|---|---|---|---|
onSelect | (value: string) => void | - | 選択された時のコールバック |
value | string | - | 検索・フィルタ対象になる値(省略時はテキスト内容を使用) |
disabled | boolean | false | 無効状態 |
CommandSeparator
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | - | 追加のCSSクラス |
CommandShortcut
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | - | ショートカットキー表示(例: ⌘K) |
className | string | - | 追加のCSSクラス |