Ariakit
/

Animated Select

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

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

Components

Styling the animation

Use the data-enter and data-leave attributes to animate the ComboboxPopover component using CSS transitions:

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

For more information on styling with Ariakit, 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