appica-dev

Autocomplete

Component

About

A text input that filters and suggests matching options from a list as the user types, with support for grouping, icons, and grid layouts.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Autocomplete to your project and fits it to your theme.

Code

How Autocomplete is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import {
  Autocomplete,
  AutocompleteInput,
  AutocompleteContent,
  AutocompleteEmpty,
  AutocompleteList,
  AutocompleteItem,
  AutocompleteGroup,
  AutocompleteLabel,
  AutocompleteCollection,
} from "@/components/ui/autocomplete";

interface ProduceGroup {
  value: string;
  items: string[];
}

const groups: ProduceGroup[] = [
  {
    value: "Fruits",
    items: [
      "Apple",
      "Banana",
      "Cherry",
      "Grapefruit",
      "Mango",
      "Orange",
      "Strawberry",
    ],
  },
  {
    value: "Vegetables",
    items: [
      "Broccoli",
      "Carrot",
      "Cucumber",
      "Lettuce",
      "Potato",
      "Spinach",
      "Tomato",
    ],
  },
  {
    value: "Herbs",
    items: ["Basil", "Mint", "Oregano", "Parsley", "Rosemary", "Thyme"],
  },
];

export default function AutocompleteGrouped() {
  return (
    <div className="w-full max-w-70">
      <Autocomplete items={groups}>
        <AutocompleteInput
          placeholder="Search produce"
          aria-label="Search produce"
        />
        <AutocompleteContent>
          <AutocompleteEmpty>No produce found.</AutocompleteEmpty>
          <AutocompleteList>
            {(group: ProduceGroup) => (
              <AutocompleteGroup key={group.value} items={group.items}>
                <AutocompleteLabel>{group.value}</AutocompleteLabel>
                <AutocompleteCollection>
                  {(item: string) => (
                    <AutocompleteItem key={item} value={item}>
                      {item}
                    </AutocompleteItem>
                  )}
                </AutocompleteCollection>
              </AutocompleteGroup>
            )}
          </AutocompleteList>
        </AutocompleteContent>
      </Autocomplete>
    </div>
  );
}

Dependencies

More by appica-dev

View all
  • Border Beam

    Border Beam

    43
  • Text Animate

    Text Animate

    19
  • Carousel

    Carousel

    14
  • Sparkline

    Sparkline

    7
  • Table of Contents

    Table of Contents

    6
  • Color Area

    Color Area

    6
  • Avatar

    Avatar

    6
  • Background Pattern

    Background Pattern

    3