I'm trying to animate the max-height of a div from 0 to 100% using Tailwind's arbitrary values feature, but it's not working:
document.getElementById("toggle").addEventListener("click", () => {
document.getElementById("txt").classList.toggle("max-h-full");
document.getElementById("txt").classList.toggle("max-h-0");
});
<script src="https://cdn.tailwindcss.com"></script>
<button id="toggle" class="m-3 p-2 border hover:bg-slate-300">Toggle text</button>
<p id="txt" class="m-3 border overflow-hidden max-h-full transition-[max-height] ease-out">
This is a text.<br>That can be collapsed.<br>Or expanded.<br>And so forth.<br>Et cetera.
</p>
It just collapses and expands instantly, without any transition of the max-height
.
The weird thing is that I do see the right properties being set in the developer tools:
transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
transition-property: max-height;
transition-duration: 150ms;
Plus of course the max-height
.
What else do I need to set or configure to make it transition?