I could not find a way to give transition to height property(which we can in pure css) so i used scale to give a transition effect
See if it helps
const bar_btn = document.getElementById('BAR_BTN');
const mobileMenu = document.getElementById('mobileMenu')
bar_btn.addEventListener('click',function()
{
mobileMenu.classList.toggle('transform');
}
);
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"/>
<nav>
<div>
<button id="BAR_BTN" class="px-10 py-2 mt-10 mx-10 w-1/4 hover:bg-green-300 bg-green-200 transition-all">button</button>
</div>
<ul id="mobileMenu" class="mx-10 p-5 border-4 border-black overflow-hidden text-xl w-1/4 origin-top duration-300 scale-y-0" >
<li>Test-1</li>
<li>Test-2</li>
<li>Test-3</li>
</ul>
</nav>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…