Ariakit
/

Animated Combobox

Animating a Combobox using CSS transitions in React. The component waits for the transition to finish before completely hiding the popover.

import * as Ariakit from "@ariakit/react";
import "./style.css";
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
);
}

Components

Styling

Ariakit will automatically assign the data-enter and data-leave attributes to the popover element when it opens and closes. You can use these attributes as selectors to add CSS transitions to the popover.

.popover {
opacity: 0;
transition: opacity 150ms;
}
.popover[data-enter] {
opacity: 1;
}

For more information, refer to 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