Make a smooth transition between width of div

Viewed 125

I have a div which contain my sidebar. To toggle it, I use a boolean, so when the user click on a the chevron, the width value change from 24rem to 6rem and vice versa. The toggle being immediate, I would like to make it smooth. I though adding a transition to my css could make it but nothing change. Is there a method to make a smooth transition between two value without using an external library.

This is the div I have.

<div className={`${isToggle ? 'w-24' : 'w-96'} transition ease-linear duration-200 h-full`}>
0 Answers
Related