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.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/commandThis 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
└── CommandItemExamples
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
| Move | What you see |
|---|---|
| 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. |
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.
| Variable | What it changes | Default |
|---|---|---|
--command-face | Palette surface | --popover |
--command-ink | Palette and search text | --popover-foreground / --foreground |
--command-accent | Highlighted command | --accent |
--command-radius | Palette corners | 14px |
--command-row-height | Command row height | 2.25rem |
--command-gap | Search and command icon spacing | 0.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
| Key | What it does |
|---|---|
| ↓ | Moves to the next item. |
| ↑ | Moves to the previous item. |
| Enter | Runs the highlighted item. |
| Backspace | Goes back a page when the search is empty. |
| Escape | Clears 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.