Componentpickers2.39 KB gzipZero dependencies

Combobox

Filterable searchable dropdown with instant keyboard filter.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add combobox

Or install the full npm package:

npm install bigbullui

Usage

tsx9 lines
import { Combobox } from "@/components/ui/combobox"; <Combobox  options={[    { value: "orch", label: "Orchestra" },    { value: "balc", label: "Balcony" },  ]}  placeholder="Select seat..."/>

Source code

combobox.tsx + 5 helpers

Zero third-party dependencies (6 local files shown in tabs below).

tsxcombobox.tsx355 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { mergeRefs, useIsMounted } from "./lib/react-compat";import { useControllableState } from "./lib/use-controllable-state";import { useFloating } from "./lib/floating";import { registerEscapeLayer } from "./lib/focus-trap"; export interface ComboboxOption {  value: string;  label: string;  disabled?: boolean;} export interface ComboboxProps {  options: ComboboxOption[];

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { Combobox } from "@/components/ui/combobox"; <Combobox />
PropTypeDescription
optionsComboboxOption[]Selectable options list. (Default: [])
valuestringControlled value.
defaultValuestringInitial value when uncontrolled. (Default: "")
onValueChange(value: string) => voidCallback invoked on value change.
placeholderstringPlaceholder text shown when empty. (Default: "Select an option...")
searchPlaceholderstringConfigures search placeholder. (Default: "Type to search...")
emptyTextstringConfigures empty text. (Default: "No items match.")
disabledbooleanDisables interaction and applies disabled styling. (Default: false)
requiredbooleanMarks the input as required for native form validation. (Default: false)
namestringForm field name submitted during form serialization.
idstringDOM element identifier for label association and testing.
aria-labelstringConfigures aria label.
animatedbooleanDual-mode: false renders instantly with no motion. Default true.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.