Ariakit
/

Select

Select a value from a list of options presented in a dropdown menu, similar to the native HTML select element. This component is based on the WAI-ARIA Combobox Pattern.

Favorite fruit
import * as Ariakit from "@ariakit/react";
import "./style.css";
export default function Example() {
return (
<div className="wrapper">
<Ariakit.SelectLabel className="label">
Favorite fruit
<Ariakit.Select className="button" />
<Ariakit.SelectPopover gutter={4} sameWidth className="popover">
<Ariakit.SelectItem className="select-item" value="Apple" />
<Ariakit.SelectItem className="select-item" value="Banana" />
<Ariakit.SelectItem className="select-item" value="Grape" disabled />
<Ariakit.SelectItem className="select-item" value="Orange" />
</div>
);
}

Examples

API

Styling

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:

.select-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