Command with motion: one highlight glides from item to item after the arrow keys or the pointer, the list's height follows what matches as you type, and the palette grows out of what opened it.
$ pnpm dlx shadcn@latest add @dashral/motion-commandInstallation
$ pnpm dlx shadcn@latest add @dashral/motion-commandAdds components/dashral/motion/command.tsx, the Command it builds on (in components/dashral/), motion and the motion files every motion component shares. Or by its full URL: https://dashral.com/r/motion-command.json
Usage
The same as Command, imported from components/dashral/motion/ (with the npm package: @dashral/motion/components/command): swap the import and it moves.
import { CommandDialog } from "@/components/dashral/motion/command"
<CommandDialog
open={open}
onOpenChange={setOpen}
groups={[
{ heading: "Go to", items: [{ label: "Dashboard", icon: <LayoutDashboard />, onSelect: () => router.push("/") }] },
]}
/>Examples
Compared with Default
The highlight jumps from item to item, and the list's height snaps as the search narrows it.
Motion
One highlight glides from item to item, the list's height follows what matches as you type, and the palette grows out of its button.
How the two editions differ in general, and which to use where: Motion.
API reference
Every prop of Command, and every attribute of the element it renders. The Motion edition adds no props of its own.
Command
Also takes every prop of cmdk(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
groups | { heading?, items: { label, value?, keywords?, icon?, shortcut?, badge?, disabled?, onSelect? }[] }[]The actions, in groups. Required. A shortcut is text ("⌘S") or key caps, e.g. two <Kbd> for a sequence such as G then O. | — |
placeholder | stringIn the search field. | "Search…" |
emptyText | ReactNodeShown when nothing matches. | "No results found." |
className | stringExtra classes, merged with cn() so yours win. | — |
CommandDialog
Also takes every prop of Radix Dialog(opens in a new tab).
| Prop | Type | Default |
|---|---|---|
groups / placeholder / emptyText | Like Command's. | — |
open / onOpenChange / trigger | Open it with state (e.g. on ⌘K) or a trigger. | — |
title / description | stringRead by screen readers (visually hidden). | "Command palette" |
CommandRoot / CommandInput / CommandList / CommandEmpty / CommandGroup / CommandItem / CommandSeparator / CommandShortcut
Building blocks, for a list of your own: Combobox and MultiSelect are made from them.
CommandRoot, CommandGroup, CommandSeparator and CommandShortcut are the default edition's, re-exported; CommandInput, CommandList, CommandEmpty and CommandItem are this edition's, for a list of your own.
Motion
- The highlight is one pill for the whole list: it glides in 0.22s on a smooth curve to the item the arrow keys or the pointer are on; the item only changes its text color.
- As you type, the list's height glides (0.28s) to fit what matches instead of snapping, up to its 20rem cap; nothing found fades in.
- When the list first shows, its items rise 4px into place; an item that comes back as the search loosens only fades in, so typing never sets the whole list moving.
- CommandDialog is the Motion edition's Dialog: it grows out of the button that opened it and, on a phone, swipes down to close. With reduced motion nothing glides or rises.