Command
A zero-dependency searchable command menu and modal CommandDialog with a spring-gliding active row highlight, spring auto-resizing list height, and IME-safe keyboard filtering.
Customize
Installation
npx shadcn@latest add @kinetic/commandUsage
Compose Command with an input and a list of groups and items.
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
CommandSeparator,
CommandShortcut,
} from "@/components/kinetic/ui/command";
export function ActionMenu() {
return (
<Command>
<CommandInput placeholder="Type a command or search..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup heading="Actions">
<CommandItem onSelect={(value) => run(value)}>
New file <CommandShortcut>Ctrl+N</CommandShortcut>
</CommandItem>
<CommandItem keywords={["preferences"]}>Settings</CommandItem>
</CommandGroup>
<CommandSeparator />
<CommandGroup heading="Danger">
<CommandItem disabled>Delete project</CommandItem>
</CommandGroup>
</CommandList>
</Command>
);
}Dialog
CommandDialog renders the command menu in a modal. It accepts open, defaultOpen, onOpenChange, title, description and showCloseButton. The title and description are read by screen readers only. Place the same input, list and items inside it.
import { CommandDialog } from "@/components/kinetic/ui/command";
<CommandDialog open={open} onOpenChange={setOpen} title="Command palette">
<CommandInput />
<CommandList>...</CommandList>
</CommandDialog>Filtering
Items are shown when their value, text or optional keywords contain the query, ignoring case. Pass a custom filter(value, search, keywords) function that returns a score, and items with a score above 0 stay visible. Or set shouldFilter={false} to filter the list yourself, for example with remote results. Use search, defaultSearch and onSearchChange to control the query.
<Command shouldFilter={false} onSearchChange={fetchResults}>
...
</Command>Selection
Control the highlighted item with value, defaultValue and onValueChange on Command. Each CommandItem accepts a value, disabled and onSelect, which receives the item value. Set loop={false} to stop arrow navigation from wrapping.
Keyboard
Arrow keys move the active row, Home and End jump to the first and last row, and Enter selects. Filtering ignores keystrokes that are part of an active IME composition. Escape clears the query when it is not empty. Use onEscape on Command to handle the Escape key yourself; CommandDialog uses it to close.
Motion preferences
The active row highlight and list height animate on springs. Use speed on Command or CommandDialog to tune them, and blurPx on CommandDialog for the modal reveal. Timing follows the current Kinetic tempo, and motion is simplified when reduced motion is enabled.
API Reference
Command
Zero-dependency command palette root with built-in filtering, IME-safe keyboard navigation, and spring highlight.
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onValueChange | string / (value: string) => void | - | Active highlighted item value. |
search / defaultSearch / onSearchChange | string / (search: string) => void | - | Controlled or uncontrolled search query string. |
shouldFilter | boolean | true | Enables automatic client-side filtering of CommandItem entries. |
loop | boolean | true | Wraps ArrowUp and ArrowDown navigation around list boundaries. |
speed | number | 1 | Speed multiplier for highlight glide and list height spring. |
CommandDialog
Portaled modal command palette with backdrop blur, focus restoration, and Escape dismissal.
| Prop | Type | Default | Description |
|---|---|---|---|
open / defaultOpen / onOpenChange | boolean / (open: boolean) => void | - | Controlled or uncontrolled modal visibility. |
title / description / showCloseButton | string / string / boolean | "Command Palette" / true | Accessible dialog title, description, and optional close button. |