I have make a nav bar using tailwind css in next.js it is responsive and working fine.
every thing is working fine but when i click the burger button it shows the list appears instantly but i want to show the bottom (un-order list) on small screen size with smooth transition and i have no idea how to make the transition smooth
- the solution of the problem i want is to make this list smoothly visible on the screen
import React, { useEffect, useState } from "react"; import { MenuAlt1Icon } from "@heroicons/react/outline"; function Header() { const [isOpen, setisOpen] = React.useState(false); const [size, setSize] = useState(0); function handleClick() { setisOpen(!isOpen); } useEffect(() => { setSize(window.innerWidth); window.addEventListener("resize", handleSize); return () => window.removeEventListener("resize", handleSize); }, []); const handleSize = () => { setSize(window.innerWidth); }; Above is the javascript code
and below is the jsx and tailwind
return ( <header> <nav className={` shadow-md px-5 ${isOpen && size < 640 && "pb-3"}`}> <button type="button" className={`${ size >= 640 ? "hidden" : "inline-block h-12 focus:outline-none" }`} onClick={handleClick} > <MenuAlt1Icon className="h-6 w-6" /> </button> <ul className={` ${ size >= 640 ? " flex h-12 items-center space-x-2 " : `${ isOpen ? `block space-y-2 border-t-2 border-gray-50 pt-2 transition duration-500 ease-linear` : `hidden` }` }`} > <li>element 1</li> <li>element 2</li> <li>element 3</li> <li>element 4</li> </ul> </nav> </header> ); } export default Header; 

