all AI news
Make an Animated Menu like Stripe with React, Tailwind, and AI
Nov. 3, 2023, 3:41 p.m. | Yoav Ganbar
DEV Community dev.to
Written by Steve Sewell.
How does Stripe make this awesome morphing menu animation?
Let’s recreate this in React with just a few lines of logic:
```ts
const [hovering, setHovering] = useState(null);
const [popoverLeft, setPopoverLeft] = useState(null);
const [popoverHeight, setPopoverHeight] = useState(null);
const refs = useRef<(HTMLElement | null)[]>([]);
const onMouseEnter = (index: number, el: HTMLElement) => {
setHovering(index);
setPopoverLeft(el.offsetLeft);
const menuElement = refs.current[index];
if (menuElement) {
setPopoverHeight(menuElement.offsetHeight);
}
};
```
We’ll also use AI and Tailwind to create the markup, …
ai animated animation logic null react steve stripe tailwindcss webdev
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
Global Data Architect, AVP - State Street Global Advisors
@ State Street | Boston, Massachusetts
Data Engineer
@ NTT DATA | Pune, MH, IN