Question: Ideas on transitioning height with <Transition />?
See original GitHub issueI know CSS doesn’t let you transition height: 0
to height: auto
so just curious if you’ve thought about any ways to accomplish this with the <Transition />
component.
I was thinking of bringing in a hook to calculate the final height of the DOM node but then I think I’d need another API to pass it to <Transition />
, maybe enterToStyle
?
<Transition
show={open}
enter="transition ease-out"
enterFrom="transform h-0 opacity-0"
enterTo="transform h-40 opacity-100"
enterToStyle={{
height: finalHeight
}}
>
Something like this. Any thoughts?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
How can I transition height: 0; to height: auto; using CSS?
First, the height transition only works between 0 and 100%, two numeric values. Since "auto" is not a numeric value, fractional increments don't ......
Read more >Using CSS Transitions on Auto Dimensions
We can't transition height , but we can transition max-height , since it has an explicit value.
Read more >How To Do CSS Transitions With Height: Auto - Carl Anderson
Method 1: Use transform. Despite its rampant use, you should avoid CSS transitions on the height or width properties (among some others). These ......
Read more >Using CSS Transitions on the Height Property
The Solution. The hack is to transition the max-height property instead of the height property. First, we have to estimate the greatest height...
Read more >How to make transition height from 0 to auto using CSS
Approach: Replace the height with max height so that the height of the container does not overcome the actual size of the container...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey guys, I actually found a way to animating “height” using Tailwind and HeadlessUI’s Transition component 😄 the key is to programmatically set the height before the animation happens:
Here’s my TypeScript-friendly version of @thien-do’s suggested implementation (brilliant, @thien-do!) with the addition of the following: