Skip to main content

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.

Suggestions
CalendarG C
Browse ComponentsG K
Motion TokensG T

Settings
Profile⌘P
Billing⌘B
Preferences⌘,
selected=none

Customize

Speed1

Installation

npx shadcn@latest add @kinetic/command

Usage

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.

PropTypeDefaultDescription
value / defaultValue / onValueChangestring / (value: string) => void-Active highlighted item value.
search / defaultSearch / onSearchChangestring / (search: string) => void-Controlled or uncontrolled search query string.
shouldFilterbooleantrueEnables automatic client-side filtering of CommandItem entries.
loopbooleantrueWraps ArrowUp and ArrowDown navigation around list boundaries.
speednumber1Speed multiplier for highlight glide and list height spring.

CommandDialog

Portaled modal command palette with backdrop blur, focus restoration, and Escape dismissal.

PropTypeDefaultDescription
open / defaultOpen / onOpenChangeboolean / (open: boolean) => void-Controlled or uncontrolled modal visibility.
title / description / showCloseButtonstring / string / boolean"Command Palette" / trueAccessible dialog title, description, and optional close button.

Notes

Always place CommandItem inside CommandGroup. On inline embedded Command menus, pass defaultValue='__none__' so cmdk does not scroll the page to the first item on mount.