Skip to content
synccn

Command

Searchable, grouped command list — the engine behind ⌘K.

Suggestions

Calendar
Search emoji
Calculator

Settings

Profile⌘P
Billing⌘B
Preferences⌘,
Changelog

Installation

$ pnpm dlx shadcn@latest add @synccn/command

First time in this project? Connect synccn with one command.

Usage

import { Command } from "@/components/ui/command";<Command groups={groups} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

Command

Searchable command list with groups and keyboard navigation. groups: [{ heading, items: [{ id, label, icon?, shortcut?, keywords?, onSelect }] }]

  • groupsrequired
    CommandGroup[]

    Grouped items to search.

  • placeholder
    string

    Default "Type a command or search…"

    Search field placeholder.

  • empty
    React.ReactNode

    Default "No results. Try another search."

    Shown when nothing matches.

  • autoFocus
    boolean

    Default true

    Focus the search field on mount.

  • onSelect
    (item: CommandItem) => void

    Called after any item runs.

  • footer
    React.ReactNode

    Content below the list, e.g. keyboard hints.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Keyboard

  • ↓or↑Move through results (wraps around)
  • EnterRun the highlighted command

Accessibility

  • Results are a listbox grouped by heading; matching is fuzzy and ranks by score.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: group, listbox, option
  • ARIA attributes: aria-label, aria-selected
  • Keys handled: ArrowUp, ArrowDown, Enter