Componentpickers1.93 KB gzipZero dependencies
Autocomplete
Typeahead search input with instant suggestions and keyboard select.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add autocompleteOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { Autocomplete } from "@/components/ui/autocomplete"; <Autocomplete options={[{ value: "1", label: "Orchestra" }]} />Source code
autocomplete.tsx + 4 helpersZero 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 />| Prop | Type | Description |
|---|---|---|
| options | AutocompleteOption[] | Selectable options list. (Default: []) |
| value | string | Controlled value. |
| defaultValue | string | Initial value when uncontrolled. (Default: "") |
| onValueChange | (val: string) => void | Callback invoked on value change. |
| onSelectOption | (option: AutocompleteOption) => void | Callback invoked on select option. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |