flowkit-ui
Components

Creatable Combobox

A combobox with autocomplete, multiselect, and creatable support.

Installation

pnpm dlx shadcn@latest add @flowkit-ui/creatable-combobox

If you haven't added the registry yet, add this to your components.json first:

{
  "registries": {
    "@flowkit-ui": "https://flowkit-ui.vzkiss.com/r/{name}.json"
  }
}

Or install directly without the registry:

pnpm dlx shadcn@latest add https://flowkit-ui.vzkiss.com/r/creatable-combobox.json

Usage

CreatableCombobox composes the shadcn/ui Combobox primitives. Import those from @/components/ui/combobox, and the creatable helpers from @/components/ui/creatable-combobox.

"use client";

import { useState } from "react";
import {
  ComboboxContent,
  ComboboxEmpty,
  ComboboxInput,
  ComboboxItem,
  ComboboxList,
} from "@/components/ui/combobox";
import {
  CreatableCombobox,
  ComboboxItemCreatable,
  isCreatableItem,
} from "@/components/ui/creatable-combobox";

const initialItems = ["Bug", "Regression", "Tech Debt"];

export function ExampleCreatableCombobox() {
  const [items, setItems] = useState(initialItems);

  return (
    <CreatableCombobox
      items={items}
      onCreateValue={(value) =>
        setItems((prev) => [...prev, value].sort((a, b) => a.localeCompare(b)))
      }
    >
      <ComboboxInput placeholder="Create a tag..." />
      <ComboboxContent>
        <ComboboxEmpty>No matches.</ComboboxEmpty>
        <ComboboxList>
          {(item) =>
            isCreatableItem(item) ? (
              <ComboboxItemCreatable key="__create__" value={item} />
            ) : (
              <ComboboxItem key={item} value={item}>
                {item}
              </ComboboxItem>
            )
          }
        </ComboboxList>
      </ComboboxContent>
    </CreatableCombobox>
  );
}

Single select supports both controlled and uncontrolled usage. Multiple select requires a controlled value prop. Creating new items requires the caller to manage both the items list and the selection.

isCreatableItem(item) is a type guard for use inside ComboboxList to differentiate creatable items from regular items.

Examples

Basic

A simple string-based single select with creatable support.

With objects

Object items with id, and label fields.

Multiple

Multiple selection requires a controlled value prop.

API Reference

CreatableCombobox wraps the shadcn/ui Combobox with Base UI’s Combobox.Root.

PropTypeDefaultDescription
onCreateValue(value: string) => voidCalled after the dropdown closes when the user confirms a new value.
createLabel(value: string) => stringCreate "${value}"Label for the create option.
createOptionPosition"first" | "last""first"Where the create option appears in the list.

onValueChange will never be called with a CreatableItem — use onCreateValue to handle new value creation.

All other props are passed through to the base-ui Combobox.Root.

Built by vzkiss. The source code is available on GitHub.

On this page