Keyframery

Combobox

The list unfolds from the field, rows cascade in and one highlight glides between options.

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/combobox

This adds components/keyframery/combobox.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 {
  Combobox,
  ComboboxContent,
  ComboboxControl,
  ComboboxInput,
  ComboboxItems,
  ComboboxList,
  ComboboxTrigger,
} from "@/components/keyframery/combobox"

const fruits = ["Apple", "Banana", "Cherry"]

export default function Usage() {
  return (
    <Combobox items={fruits}>
      <ComboboxControl>
        <ComboboxInput placeholder="Fruit" />
        <ComboboxTrigger aria-label="Show fruit" />
      </ComboboxControl>
      <ComboboxContent>
        <ComboboxList>{(state) => <ComboboxItems items={state.items} />}</ComboboxList>
      </ComboboxContent>
    </Combobox>
  )
}

Anatomy

How the parts fit together:

Combobox
├── ComboboxControl
│   ├── ComboboxInput
│   └── ComboboxTrigger
└── ComboboxContent
    └── ComboboxList
        └── ComboboxItems

Examples

Basic

Type to filter, then pick one. Unlike an autocomplete, the value must be one of the items.

Groups

Pass groups as data, or write ComboboxGroup and ComboboxGroupLabel yourself.

Several values

multiple keeps the list open and shows each pick as a chip. Backspace removes the last one.

Motion

MoveWhat you see
UnfoldThe list unfolds from the field.
CascadeOptions arrive one after another.
GlideOne highlight glides between options.
DrawThe check on the chosen option draws itself.

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

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

"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
--combobox-faceInput, chips and popup surfaces--background / --accent (dark chips) / --popover
--combobox-inkLabel, input, checks and popup text--foreground / --popover-foreground
--combobox-accentHighlighted option surface--accent
--combobox-radiusPopup corners14px
--combobox-heightInput and chips minimum height2.25rem

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 combobox reference.

Combobox

Prop

Type

ComboboxContent

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

Prop

Type

ComboboxItems

Prop

Type

ComboboxChip

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

Prop

Type

ComboboxClear

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

Prop

Type

ComboboxCreate

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

Prop

Type

ComboboxItem

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

Prop

Type

ComboboxItemIcon

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

Prop

Type

ComboboxItemIndicator

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

Prop

Type

ComboboxValue

Prop

Type

Other parts

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

  • ComboboxControl: a <div>
  • ComboboxInput: a <input>
  • ComboboxTrigger: a <button>
  • ComboboxList: a <div>
  • ComboboxArrow: a <div>
  • ComboboxChipRemove: a <button>
  • ComboboxChips: a <div>
  • ComboboxChipsOverflow: a <span>
  • ComboboxEmpty: a <div>
  • ComboboxGroup: a <div>
  • ComboboxGroupLabel: a <div>
  • ComboboxItemText: a <span>
  • ComboboxLabel: a <label>
  • ComboboxSelectAll: a <div>
  • ComboboxSeparator: a <div>
  • ComboboxStatus: a <div>
  • ComboboxValueIcon: a <span>

Keyboard

KeyWhat it does
↓Opens the list, or moves to the next item.
↑Moves to the previous item.
EnterSelects the highlighted item.
BackspaceWith several values, removes the last chip when the field is empty.
EscapeCloses the list.

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 combobox with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.

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

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

Questions

How does the animated Combobox for UI SDK move?

Unfold: The list unfolds from the field. Cascade: Options arrive one after another. Glide: One highlight glides between options. Draw: The check on the chosen option draws itself.

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

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/combobox instead. It has the same parts and props as @ui-sdk/react/combobox and adds motion only.

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

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

All components

On this page