Componentpickers1.93 KB gzipZero dependencies

Autocomplete

Typeahead search input with instant suggestions and keyboard select.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

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

npx bigbullui add autocomplete

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { Autocomplete } from "@/components/ui/autocomplete"; <Autocomplete options={[{ value: "1", label: "Orchestra" }]} />

Source code

autocomplete.tsx + 4 helpers

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

tsxautocomplete.tsx270 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 { useFloating } from "./lib/floating";import { registerEscapeLayer } from "./lib/focus-trap"; export interface AutocompleteOption {  value: string;  label: string;  category?: string;} export interface AutocompleteProps  extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> {  options: AutocompleteOption[];

Props

Interactive Prop Playground

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

tsx3 lines
import { Autocomplete } from "@/components/ui/autocomplete"; <Autocomplete />
PropTypeDescription
optionsAutocompleteOption[]Selectable options list. (Default: [])
valuestringControlled value.
defaultValuestringInitial value when uncontrolled. (Default: "")
onValueChange(val: string) => voidCallback invoked on value change.
onSelectOption(option: AutocompleteOption) => voidCallback invoked on select option.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.