Skip to content
Ballpoint

Combobox

A field you type in to filter a list, boxed with the pen: pick one, or several as circled chips.

From shadcn/ui
Built on Base UI Combobox

Installation

pnpm dlx shadcn@latest add @ballpoint/combobox

Usage

tsx
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList } from "@/components/ui/combobox"

const frameworks = ["Next.js", "SvelteKit", "Nuxt.js"]

<Combobox items={frameworks}>
  <ComboboxInput placeholder="Select a framework" />
  <ComboboxContent>
    <ComboboxEmpty>No framework found.</ComboboxEmpty>
    <ComboboxList>
      {(item) => <ComboboxItem key={item} value={item}>{item}</ComboboxItem>}
    </ComboboxList>
  </ComboboxContent>
</Combobox>

Examples

With a clear button

A cross that empties the field.

Groups

Items under headings, ruled apart.

Multiple

Chosen items sit in the box as chips, with a cross each; the list opens under the box.

API reference

items
T[]

What to choose from: strings, or objects with a value and label. Grouped items are { value, items }.

value / defaultValue
T

The chosen item (an array with `multiple`), controlled or not.

multiple
default false
boolean

Choose several; use ComboboxChips and ComboboxChip for the box.

ComboboxInput showTrigger / showClear
default true / false
boolean

A chevron to open the list; a cross to empty the field.

ComboboxContent anchor
RefObject

What the list lines up under. Use useComboboxAnchor() for the chips box.

seed
string | number

Pins the drawing.

Every other prop goes to Base UI's Combobox.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, shadow, weight and speed, as props or from the nearest InkProvider. What each one does.