Fill in a React input field with autocomplete & autosuggest functionalities. Choose from a list of suggested values with full keyboard support. This component is based on the WAI-ARIA Combobox Pattern.

import "./style.css";
import * as Ariakit from "@ariakit/react";
export default function Example() {
return (
<Ariakit.ComboboxLabel className="label">
Your favorite fruit
<Ariakit.Combobox placeholder="e.g., Apple" className="combobox" />
<Ariakit.ComboboxPopover gutter={4} sameWidth className="popover">
<Ariakit.ComboboxItem className="combobox-item" value="Apple">
🍎 Apple
<Ariakit.ComboboxItem className="combobox-item" value="Grape">
🍇 Grape
<Ariakit.ComboboxItem className="combobox-item" value="Orange">
🍊 Orange
<Ariakit.ComboboxItem className="combobox-item" value="Strawberry">
🍓 Strawberry
<Ariakit.ComboboxItem className="combobox-item" value="Watermelon">
🍉 Watermelon




Styling the active item

When browsing the list with a keyboard (or hovering over items with the mouse when the focusOnHover prop is true), the active item element will have a data-active-item attribute. You can use this attribute to style the active item:

.combobox-item[data-active-item] {
background-color: hsl(204 100% 40%);
color: white;

Learn more on the Styling guide.

Stay tuned

Join 1,000+ subscribers and receive monthly tips & updates on new Ariakit content.

No spam. Unsubscribe anytime. Read latest issue