You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

at-react-autocomplete-1

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

at-react-autocomplete-1

An auto complete dropdown component for React with TypeScript support.

2.0.0
latest
npmnpm
Version published
Weekly downloads
405
Maintainers
1
Weekly downloads
 
Created
Source

![npm version](https://badge.fury.io/js/at-react-autocomplete-1 .svg)
License: MIT

A highly customizable, keyboard-accessible autocomplete dropdown component for React + TypeScript.

✨ Features

  • ⌨️ Full keyboard navigation (↑/↓ arrows, Enter, Escape)
  • Built-in debouncing for API calls
  • 🔄 Loading state support
  • 🎨 Customizable item rendering with renderItem
  • 📏 Minimum search length requirement
  • 🖱️ Mouse + keyboard interaction support
  • 🛠 TypeScript-first design
  • 🎛 Supports controlled or uncontrolled input
  • 🎨 Accepts className for easy styling

📦 Installation

npm install at-react-autocomplete-1

# or
yarn add at-react-autocomplete-1


Props

PropTypeDescription
suggestionsT[]Array of suggestions to display
onInputChange(value: string) => voidCalled when input changes (debounced)
onSelect(item: T) => voidCalled when item is selected
renderItem(item: T) => React.ReactNodeRenders each dropdown item (default: text)
getDisplayValue?(item: T) => stringValue to display in input when selected (default: item.toString())
onEnter?(inputValue: string) => voidCalled when the ENTER button is pressed
isLoading?booleanShows loading indicator
placeholder?stringInput placeholder text
className?stringCustom class names for container
inputClassNamestringCustom class names for the input element
inputValue?stringControlled input value
setInputValue?(value: string) => voidUpdates controlled input value
minSearchLength?numberMinimum chars before searching (default: 2)
debounceDelay?numberDebounce delay in ms (default: 300)

Example

import React, { useState } from "react";
import AutocompleteDropdown from "at-react-autocomplete-1";

interface Country {
  id: number;
  name: string;
  flag: string;
}

export default function Page() {
  const [suggestions, setSuggestions] = useState<Country[]>([]);
  const [isLoading, setIsLoading] = useState(false);
  const [selectedCountry, setSelectedCountry] = useState<Country | null>(null);

  // Mock API fetch function
  const fetchCountries = async (query: string) => {
    if (query.length < 2) {
      setSuggestions([]);
      return;
    }

    setIsLoading(true);
    try {
      // In a real app, you would fetch from an actual API
      // const response = await fetch(`/api/countries?q=${query}`);
      // const data = await response.json();

      // Mock data
      const mockCountries: Country[] = [
        { id: 1, name: "United States", flag: "🇺🇸" },
        { id: 2, name: "United Kingdom", flag: "🇬🇧" },
        { id: 3, name: "Canada", flag: "🇨🇦" },
        { id: 4, name: "Australia", flag: "🇦🇺" },
        { id: 5, name: "Germany", flag: "🇩🇪" },
        { id: 6, name: "France", flag: "🇫🇷" },
        { id: 7, name: "Japan", flag: "🇯🇵" },
      ];

      // Filter mock data based on query
      const filtered = mockCountries.filter((country) =>
        country.name.toLowerCase().includes(query.toLowerCase())
      );

      // Simulate network delay
      await new Promise((resolve) => setTimeout(resolve, 500));
      setSuggestions(filtered);
    } catch (error) {
      console.error("Error fetching countries:", error);
      setSuggestions([]);
    } finally {
      setIsLoading(false);
    }
  };

  const handleInputChange = (value: string) => {
    fetchCountries(value);
  };

  const handleSelect = (country: Country) => {
    setSelectedCountry(country);
    alert("Selected country: " + country.name);
  };

  const renderCountryItem = (country: Country) => (
    <div className="flex items-center gap-2 hover:bg-accent p-2">
      <span className="text-xl">{country.flag}</span>
      <span>{country.name}</span>
    </div>
  );

  return (
    <AutocompleteDropdown<Country>
      suggestions={suggestions}
      onInputChange={handleInputChange}
      onSelect={handleSelect}
      renderItem={renderCountryItem}
      getDisplayValue={(country) => country.name}
      onEnter={(inputValue) => console.log("Value", inputValue)}
      isLoading={isLoading}
      placeholder="Search countries..."
      className=" border rounded-md  "
      inputClassName="p-2"
    />
  );
}

Do you also want me to add badges for CI status, bundle size (bundlephobia), and TypeScript support so it looks like a polished open-source package?

Keywords

react

FAQs

Package last updated on 07 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.