Adding a smooth transition to the expansion of a div when the contents change (React)

Viewed 104

I'm currently working on a website where I have a short description and a toggle button which will expand that description into a long description. It looks something like this: https://codesandbox.io/s/nervous-hugle-q27lz?file=/src/App.js

I'd like to make the transition when the toggle button is clicked look smoother. I've read a few posts which suggest a div height must be set for this to work, but the height is currently auto because the content is dynamic (from a headless CMS).

Does anyone know how I can do this? I'd be very grateful for the help, thanks.

0 Answers
Related