Components

Command

The shadcn/ui Command menu (cmdk) with a result list that eases its height as you type, a clear selected row and keycap shortcuts — plus an animated React ⌘K command palette block built with Motion, with a gliding highlight, recent items and nested pages.

  • Drop-in shadcn API
  • cmdk filtering
  • ⌘K palette
  • Nested pages
  • Motion block

Try “Change theme…”, then Backspace to go back.

Installation

$ npx shadcn@latest add https://duskui.com/r/command.json

Replaces components/ui/command.tsx with the same exports and props, including CommandDialog's title, description, className and showCloseButton. It uses the DuskUI Dialog, which the CLI installs for you. Animations are CSS, so the base needs no Motion.

Usage

search-menu.tsx
import {
  Command,
  CommandEmpty,
  CommandGroup,
  CommandInput,
  CommandItem,
  CommandList,
  CommandShortcut,
} from "@/components/ui/command"

export function SearchMenu() {
  return (
    <Command className="rounded-xl border">
      <CommandInput placeholder="Type a command or search…" />
      <CommandList>
        <CommandEmpty>No results found.</CommandEmpty>
        <CommandGroup heading="Suggestions">
          <CommandItem onSelect={() => console.log("calendar")}>Calendar</CommandItem>
          <CommandItem>
            Settings
            <CommandShortcut>⌘S</CommandShortcut>
          </CommandItem>
        </CommandGroup>
      </CommandList>
    </Command>
  )
}

Examples

Default

An inline menu. Type to filter: the list eases to its new height instead of jumping, the selected row gets a neutral highlight and its icon brightens, and shortcuts render as small keycaps. Disabled items are skipped by the arrow keys.

Dialog

CommandDialog wraps the menu in the DuskUI Dialog and positions it near the top of the screen like a real palette. Its accessible title and description are visually hidden but announced. Bind a shortcut yourself with a keydown listener.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Command Palette

A data-driven ⌘K palette. It fades in from the top, a highlight glides between items as you arrow or hover (a shared Motion layoutId), and actions you run surface under Recent. Items with a page open a nested page: the list slides in from the side you're travelling, a breadcrumb shows where you are and the panel eases to the new height. Backspace on an empty search or Escape steps back. This demo uses ⌘J so it doesn't clash with the site search.

Try “Change theme…”, then Backspace to go back.

$ npx shadcn@latest add https://duskui.com/r/command-palette.json
PropTypeDefaultDescription
groupsCommandPaletteGroup[]—Groups on the home page: { heading, items }.
pagesCommandPalettePage[][]Nested pages: { id, title, placeholder?, groups }.
items[]{ id, label, icon?, description?, shortcut?, keywords?, disabled?, page?, onSelect?, keepOpen? }—page opens a nested page; otherwise onSelect runs and the palette closes unless keepOpen.
open / defaultOpen / onOpenChangeboolean / boolean / (open: boolean) => void—Open state.
triggerReactElement—Element that opens the palette, usually a Button.
hotkeystring | null"k"Key that toggles the palette with ⌘ / Ctrl. null disables it.
defaultRecent / recentLimitstring[] / number[] / 3Initial recent item ids and how many to keep. 0 hides Recent.
placeholder / emptyMessagestring / ReactNode—Search placeholder and the no-results message.
title / descriptionstring—Accessible (visually hidden) dialog title and description.

API Reference

Same parts as shadcn/ui: Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator and CommandShortcut. Each forwards the cmdk props.

PropTypeDefaultDescription
value / onValueChangestring / (value: string) => void—Controlled selected item (on Command).
filter / shouldFilter / loop(value, search, keywords) => number / boolean / boolean—Custom scoring, turn filtering off for async results, wrap arrow keys (on Command).
value / onValueChangestring / (search: string) => void—Controlled search text (on CommandInput).
onSelect / value / keywords / disabled(value) => void / string / string[] / boolean—On CommandItem. keywords add search terms.
headingReactNode—Group title (on CommandGroup).
title / description / showCloseButtonstring / string / boolean"Command Palette" / … / trueOn CommandDialog, plus all Dialog props.

Accessibility

  • cmdk renders a combobox input that controls a listbox; the selected option is exposed with aria-selected and aria-activedescendant, so focus stays in the input.
  • Arrow keys (and Ctrl+N/P, Ctrl+J/K) move the selection, Home/End jump, Enter runs the item. Disabled items are skipped.
  • CommandDialog and the Command Palette are Radix Dialogs: focus is trapped, Escape closes (in the palette it first steps back out of nested pages) and focus returns to the trigger.
  • The palette's breadcrumb is a labelled nav with aria-current on the current page and a real Back button.
  • Under prefers-reduced-motion the list height and highlight change instantly, pages don't slide and the palette only fades.