I have this component appear on button click. I was wondering whether there is a simple ease in then expand or popout animation. To make it look smoother in transition rather than appearing?
const CardExample = () => {
const [show, setShow] = useState(false);
const handleClick = () => {
setShow(!show);
};
return (
<div>
<Button onClick={handleClick} type="primary">
Show Card
</Button>
<Card style={{ display: show && "none" }}>This is my card</Card>
</div>
);
};
You can try using opacity
instead of display here like below and use transition
to add the animation
const CardExample = () => {
const [show, setShow] = useState(false);
const handleClick = () => {
setShow(!show);
};
const cardStyle = {
opacity: show ? 0 : 1,
transition: "all 1s ease-in"
};
return (
<div>
<Button onClick={handleClick} type="primary">
Show Card
</Button>
<Card style={cardStyle}>This is my card</Card>
</div>
);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With