---
title: Autocomplete
description: An input that suggests options as you type.
links:
doc: https://base-ui.com/react/components/autocomplete#api-reference
---
## Installation
CLI
Manual
```bash
npx shadcn@latest add @coss/autocomplete
```
Install the following dependencies:
```bash
npm install @base-ui/react
```
Copy and paste the following code into your project.
Update the import paths to match your project setup.
## Usage
```tsx
import {
Autocomplete,
AutocompleteEmpty,
AutocompleteInput,
AutocompleteItem,
AutocompleteList,
AutocompletePopup,
} from "@/components/ui/autocomplete"
```
```tsx
const items = [
{ value: "apple", label: "Apple" },
{ value: "banana", label: "Banana" },
{ value: "orange", label: "Orange" },
{ value: "grape", label: "Grape" },
]
No results found.
{(item) => {item.label}}
```
## API Reference
### Autocomplete
The root autocomplete component. Manages the autocomplete state and provides context to child components.
| Prop | Type | Description |
| ---------- | ----------------------------------------- | --------------------------------------------------- |
| `items` | `readonly unknown[]` | The array of items to display in the autocomplete |
| `open` | `boolean` | Controls whether the popup is open |
| `...props` | `React.ComponentProps` | All Base UI Autocomplete props are supported |
### AutocompleteInput
The input field component with extended features for size variants and addon support.
| Prop | Type | Default | Description |
| -------------- | --------------------------------- | ----------- | ------------------------------------------------------------------------------------------------ |
| `size` | `"sm" \| "default" \| "lg"` | `"default"` | The size variant of the input field |
| `startAddon` | `React.ReactNode` | - | Element to display at the start (left side) of the input, such as an icon |
| `showTrigger` | `boolean` | `false` | Whether to display a trigger button (chevron icon) on the right side of the input |
| `showClear` | `boolean` | `false` | Whether to display a clear button (X icon) on the right side of the input when there is a value |
| `triggerProps` | `Autocomplete.Trigger.Props` | - | Props forwarded to the internal trigger button, useful for overriding `aria-label` |
| `clearProps` | `Autocomplete.Clear.Props` | - | Props forwarded to the internal clear button, useful for overriding `aria-label` |
| `className` | `string` | - | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete Input props | - | All standard autocomplete input attributes are supported |
### AutocompletePopup
The popup container that displays the autocomplete suggestions.
| Prop | Type | Description |
| -------------- | --------------------------------------------- | ------------------------------------------------ |
| `className` | `string` | Additional CSS classes to apply to the component |
| `portalProps` | `Autocomplete.Portal.Props` | Props forwarded to the internal portal (`keepMounted`, `container`, etc.); see Base UI Combobox portal API (autocomplete reuses it) |
| `...props` | Base UI Autocomplete Popup props | All standard autocomplete popup attributes are supported |
### AutocompleteList
A scrollable container for autocomplete items.
| Prop | Type | Description |
| ----------- | ---------------------------------------- | ------------------------------------------------ |
| `className` | `string` | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete List props | All standard autocomplete list attributes are supported |
### AutocompleteItem
An individual selectable autocomplete item.
| Prop | Type | Description |
| ----------- | ---------------------------------------- | ------------------------------------------------ |
| `value` | `unknown` | The value of the item |
| `className` | `string` | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete Item props | All standard autocomplete item attributes are supported |
### AutocompleteEmpty
Displays a message when no results are found.
| Prop | Type | Description |
| ----------- | ----------------------------------------- | ------------------------------------------------ |
| `className` | `string` | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete Empty props | All standard autocomplete empty attributes are supported |
### AutocompleteGroup
Groups related autocomplete items together.
| Prop | Type | Description |
| ----------- | ----------------------------------------- | ------------------------------------------------ |
| `items` | `readonly unknown[]` | The array of items in this group |
| `className` | `string` | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete Group props | All standard autocomplete group attributes are supported |
### AutocompleteGroupLabel
Displays a label for an autocomplete group.
| Prop | Type | Description |
| ----------- | ---------------------------------------------- | ------------------------------------------------ |
| `className` | `string` | Additional CSS classes to apply to the component |
| `...props` | Base UI Autocomplete Group Label props | All standard autocomplete group label attributes are supported |
### AutocompleteCollection
Used to wrap items within a group for rendering.
| Prop | Type | Description |
| ----------- | ---------------------------------------------- | ------------------------------------------------ |
| `...props` | Base UI Autocomplete Collection props | All standard autocomplete collection attributes are supported |
## Examples
### Disabled
### Small Size
### Large Size
### With Label
### Inline Autocomplete
Autofill the input with the highlighted item while navigating with arrow keys.
### Auto Highlight
Automatically highlight the first matching option.
### With Clear Button
### With Trigger and Clear Buttons
### With Start Addon
Display an icon or other element at the start of the input using the `startAddon` prop.
### With Groups
### With Limit Results
### Async Search
### Form Integration