Keyframery

Command

A command palette whose rows cascade in, with one highlight gliding between results and pages sliding sideways.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/command

This adds components/keyframery/command.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { Command, CommandInput, CommandItem, CommandList, CommandSearch } from "@/components/keyframery/command"

export default function Usage() {
  return (
    <Command aria-label="Commands">
      <CommandSearch>
        <CommandInput placeholder="Type a command…" />
      </CommandSearch>
      <CommandList>
        <CommandItem value="new">New file</CommandItem>
        <CommandItem value="open">Open…</CommandItem>
      </CommandList>
    </Command>
  )
}

Anatomy

How the parts fit together:

Command
├── CommandSearch
│   └── CommandInput
└── CommandList
    └── CommandItem

Examples

Basic

Fuzzy search over items, in groups. Each item can show its shortcut.

In a dialog

Put it in a Dialog for a command palette. shortcut on the trigger opens it with ⌘K or Ctrl+K.

Nested pages

An item with page opens a second list inside the palette. Backspace in an empty search goes back.

Commands as data

Pass items to Command and leave CommandList empty: it renders the commands, groups and separators for you, ranked as you type. A command with items opens a page of its own.

Motion

MoveWhat you see
CascadeResults arrive one after another, on open and on every page change.
GlideOne highlight glides between results.
DirectionPages slide sideways as you go deeper.

Timing and springiness follow the motion style you set. To change how fast this command moves, pass speed:

<Command speed="fast">
  …
</Command>

"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.

Theming

Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.

VariableWhat it changesDefault
--command-facePalette surface--popover
--command-inkPalette and search text--popover-foreground / --foreground
--command-accentHighlighted command--accent
--command-radiusPalette corners14px
--command-row-heightCommand row height2.25rem
--command-gapSearch and command icon spacing0.625rem

API reference

Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK command reference.

Command

Renders a <div>, and takes its props too.

Prop

Type

CommandItem

Renders a <div>, and takes its props too.

Prop

Type

CommandItemIcon

Renders a <span>, and takes its props too.

Prop

Type

CommandItems

Prop

Type

CommandPage

Prop

Type

CommandShortcut

Renders a <span>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • CommandSearch: a <div>
  • CommandInput: a <input>
  • CommandList: a <div>
  • CommandEmpty: a <div>
  • CommandFooter: a <div>
  • CommandGroup: a <div>
  • CommandGroupLabel: a <div>
  • CommandItemText: a <span>
  • CommandSeparator: a <div>
  • CommandStatus: a <div>

Keyboard

KeyWhat it does
↓Moves to the next item.
↑Moves to the previous item.
EnterRuns the highlighted item.
BackspaceGoes back a page when the search is empty.
EscapeClears the search, or goes back a page.

Accessibility

Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.

Swap the import

Already using UI SDK's command with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

// Before
import { … } from "@ui-sdk/react/command"

// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/command"

Questions

How does the animated Command for UI SDK move?

Cascade: Results arrive one after another, on open and on every page change. Glide: One highlight glides between results. Direction: Pages slide sideways as you go deeper.

Do I need Motion or Framer Motion for the animated Command?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

Can I keep my own styling and only take the motion?

Yes. Import from @/components/keyframery/primitives/command instead. It has the same parts and props as @ui-sdk/react/command and adds motion only.

What happens to the Command when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page