Combobox with motion: its list is the Motion edition's Command, so one highlight glides from option to option and the height follows what matches; the picked option's tick draws itself and a new value rises into the field.
$ pnpm dlx shadcn@latest add @dashral/motion-comboboxInstallation
$ pnpm dlx shadcn@latest add @dashral/motion-comboboxAdds components/dashral/motion/combobox.tsx, the Combobox 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-combobox.json
Usage
The same as Combobox, imported from components/dashral/motion/ (with the npm package: @dashral/motion/components/combobox): swap the import and it moves.
import { Combobox } from "@/components/dashral/motion/combobox"
<Combobox
label="Assignee"
options={people}
value={assignee}
onValueChange={setAssignee}
placeholder="Unassigned"
/>Examples
Compared with Default
The highlight jumps from option to option, the list's height snaps as you type, and a new value replaces the old at once.
Motion
One highlight glides from option to option, the list follows what matches, the picked option's tick draws itself, and a new value rises into the field.
How the two editions differ in general, and which to use where: Motion.
API reference
Every prop of Combobox, and every attribute of the element it renders. The Motion edition adds no props of its own.
Combobox
| Prop | Type | Default |
|---|---|---|
options | { value, label, icon?, description?, disabled? }[]What can be picked. Required. icon sits before the label (an avatar, a flag), also in the field once picked; description is a second line, searched too. | — |
value / defaultValue | stringPicked value, controlled or initial. Picking it again clears it. | "" |
onValueChange | (value: string) => voidCalled with the new value. | — |
placeholder / searchPlaceholder / emptyText | stringTexts for the button, the search field and no results. | — |
id / disabled / aria-label / className | Passed to the trigger button. | — |
label | ReactNodeShown above, linked to the control. | — |
description | ReactNodeA hint under the control. | — |
error | boolean | ReactNodetrue shows the error style; a message also shows under the control. | — |
labelAction | ReactNodeAt the end of the label's row, e.g. a “Forgot password?” link or the current value. | — |
withAsterisk | booleanMarks the label with an asterisk, e.g. alongside required. | false |
classNames | { root, label, description, error, trigger, content, item }Classes for each part. | — |
Motion
- Its list is the Motion edition's Command: one highlight glides (0.22s, a smooth curve) to the option the arrow keys or the pointer are on, the list's height glides to fit what matches as you type, and the options rise in as it opens.
- The picked option's tick draws itself, a stroke from start to end.
- A new value rises 8px into the field as the old one leaves upward, in the same place; clearing it brings the placeholder back the same way.
- Its description and error come and go like the other motion fields: an error grows in under it and folds away. With reduced motion it only fades.