Overlays & Actions
Command
Command palette surface: filterable list via `CommandInput` + `value` on each `CommandItem`. Official shadcn uses `cmdk` (React); Kamod implements the same UX with Preact signals and `data-match` visibility for `CommandEmpty`. Reveal the right amount of context without losing the user's place in the interface. Keep the trigger, content and dismissal behavior working as one interaction. Import it from @/components/kamod-ui/command.
Source · Design reference · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Use @kamod-ch/ui — no cmdk dependency. For modal palettes, wrap with CommandDialog (Dialog + padded DialogContent).
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
CommandItem requires a value string used for filtering (case-insensitive substring). Use onSelect or onClick for actions. CommandEmpty appears only when the query is non-empty and no item matches. CommandList measures matches after layout. Inside CommandDialog, drop the inner Command border: class="rounded-none border-0 shadow-none".
import { Command } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Command in Different Contexts, from the starting pattern to the compositions below. Begin with Inline Demo, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Inline Demo
Organize Commands Around Tasks. Compose a command list from groups, separators, shortcuts and icons to make available actions searchable. The inline example keeps the list in the page, allowing you to inspect its organization before adding a dialog layer.
Connect each item's selection handler to a real action, provide a clear empty state, and remember that a displayed shortcut does not register a keyboard listener by itself.
// command-doc.tsx — CommandDemoPreviewDialog: Basic
Keep the Command Surface Easy to Enter and Leave. Use CommandDialog with controlled open and onOpenChange when the command palette should appear over the current screen. The command list owns its choices while the parent decides when the palette is available.
Name the launcher, preserve dismissal and focus return, and keep command execution separate from the dialog's visibility state so actions do not accidentally run twice.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthDialog: Shortcuts
Advertise Shortcuts that Actually Exist. Add CommandShortcut beside an action label to show a keyboard hint in a consistent trailing position. The hint documents a shortcut; the application must still register and handle that key combination where appropriate.
Avoid conflicting with browser or assistive-technology shortcuts, and keep a normal selectable command available for people who do not use the advertised key sequence.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthDialog: Groups
Separate Frequent Suggestions from Broader Settings. Separate suggestions and settings with named groups and CommandSeparator. This preserves the relationship between related actions, helping readers interpret the list even before they begin filtering its contents.
Keep category names stable and remove empty groups when appropriate; commands should remain understandable when search results appear outside their original context.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthDialog: Scrollable
Constrain the List without Hiding Navigation. Constrain CommandList with max-h-80 when many actions would otherwise make the palette too tall. The surrounding dialog stays compact while the results form a scrollable area within it.
Test keyboard movement into offscreen items and long labels, and keep the search field and empty-result feedback visible without requiring users to scroll the entire page.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Command using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Command
CommandProps
| Prop / type | Description |
|---|---|
autoHighlight | First visible item gets `data-highlighted`; enables ArrowUp/Down + Enter in `CommandInput`.
|
children | Configure
|
class | Configure
|
hasVisibleItems | External visibility signal; updated by `CommandList` when provided.
|
query | External filter signal (e.g. combobox inline input shares query with the list).
|
CommandDialog
CommandDialogProps
| Prop / type | Description |
|---|---|
children | Configure
|
contentClass | Passed to `DialogContent` for width (default command palette sizing).
|
defaultOpen | Configure
|
onOpenChange | Configure
|
open | Configure
|
CommandEmpty
CommandEmptyProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
CommandGroup
CommandGroupProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
heading | Configure
|
CommandInput
CommandInputProps
| Prop / type | Description |
|---|---|
class | Configure
|
onInput | Configure
|
onKeyDown | Configure
|
CommandItem
CommandItemProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
disabled | Configure
|
onClick | Configure
|
onSelect | Configure
|
value | Used for case-insensitive filtering against the query.
|
CommandList
CommandListProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
onMount | Notified when the list root mounts (e.g. combobox inline input forwards keyboard to the list).
|
CommandSeparator
CommandSeparatorProps
| Prop / type | Description |
|---|---|
class | Configure
|
CommandShortcut
CommandShortcutProps
| Prop / type | Description |
|---|---|
children | Configure
|
class | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
CommandContextValue
7 declared fieldsCommandContextValueCommand.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandContextValue before adapting it.query, hasVisibleItems, autoHighlight, highlightedIndex, listRef, moveHighlight, activateHighlightedCommand Props
4 declared fieldsCommandPropsCommand.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandProps before adapting it.CommandDialog Props
5 declared fieldsCommandDialogPropsCommandDialog.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandDialogProps before adapting it.CommandEmpty Props
1 declared fieldCommandEmptyPropsCommandEmpty.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandEmptyProps before adapting it.CommandGroup Props
2 declared fieldsCommandGroupPropsCommandGroup.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandGroupProps before adapting it.CommandInput Props
DeclarationCommandInputPropsCommandInput.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandInputProps before adapting it.CommandItem Props
3 declared fieldsCommandItemPropsCommandItem.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandItemProps before adapting it.valueCommandList Props
2 declared fieldsCommandListPropsCommandList.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandListProps before adapting it.CommandSeparator Props
DeclarationCommandSeparatorPropsCommandSeparator.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandSeparatorProps before adapting it.CommandShortcut Props
1 declared fieldCommandShortcutPropsCommandShortcut.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CommandShortcutProps before adapting it.Accessibility
Build the Complete Interaction, Including the Parts Outside Command. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
Command filters button items through a native input. autoHighlight defaults to false; when enabled, CommandInput handles Up/Down and Enter for highlighted-item activation. The implementation should not be described as a complete combobox/listbox pattern by default.
Labels and Relationships
Label the search input independently of its placeholder, and write action names that stand on their own. Shortcuts are supplementary hints. Group headings help sighted scanning, but verify their relationships in the rendered accessibility tree.
Keyboard and Focus
With autoHighlight off, keep matching item buttons reachable through ordinary focus. With it on, verify that highlight movement and activation remain understandable to screen-reader users as well as visually. Test an empty query, no results and disabled matches.
States and Integration Details
A highlighted background is not automatically an announced active descendant. If embedding Command in a dialog, the outer dialog still needs a name, dismissal and focus return. Do not imply unavailable shortcuts or selection semantics through decorative text.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Search and activate an enabled result using each configured keyboard path.
- Read result changes with a screen reader and inspect whether the highlighted result is conveyed.
- Clear the query, disable a matching action and close any enclosing dialog without losing focus.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.