Is there a way to smoothly expand a div when new content is added?
const [render, setRender] = useState(false)
const showHide= () => {
setRender(!render)
}
return (
<div className="container">
<h1>TEST CONTAINER</h1>
{render && <Paragprah />}
<button type="button" class="btn btn-primary" onClick={showHide}>Primary</button>
</div>
);
}
CSS
.container {
margin-left: 30%;
margin-top: 10%;
width: 500px;
height: auto;
background-color: whitesmoke;
}
In the code above, a component is rendered when a button is clicked. However, when new content is added to the div, it expands instantly instead of smoothly. I need the expansion to be gradual. Click here to see an example video. A fixed height won't work for me as the content comes from an API and varies in length each time. Any suggestions on achieving a smooth transition while still accommodating dynamic content?