Smooth Resizing Animation with Rotating Text #312
-
I was looking at the animation for rotating text on the website and noticed that the size of the overall element transitions when the length of the text changes. I tried my best to do this with tailwind, both by editing the RotatingText component and in the page using the component but I'm just not able to replicate it. How is it done on the website? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello, don't forget you have access to the code in this repository, meaning all of it, so you can just open the specific demo component to check: https://github.com/DavidHDev/react-bits/blob/main/src/demo/TextAnimations/RotatingTextDemo.jsx The part you're looking for is here: <div className="rotating-text-demo">
<LayoutGroup>
<motion.p className="rotating-text-ptag" layout>
<motion.span
className="pt-0.5 sm:pt-1 md:pt-2"
layout
transition={{ type: "spring", damping: 30, stiffness: 400 }}
>
Creative{" "}
</motion.span>
<RotatingText
texts={words}
mainClassName="rotating-text-main"
staggerFrom={"last"}
initial={{ y: "100%" }}
animate={{ y: 0 }}
exit={{ y: "-120%" }}
staggerDuration={0.025}
splitLevelClassName="rotating-text-split"
transition={{ type: "spring", damping: 30, stiffness: 400 }}
rotationInterval={2000}
/>
</motion.p>
</LayoutGroup>
</div> And the CSS that goes with it is here:
RotatingText itself is simply a text animation, the demo on the docs was made like that just to spice things up a bit visually. |
Beta Was this translation helpful? Give feedback.
Hello, don't forget you have access to the code in this repository, meaning all of it, so you can just open the specific demo component to check: https://github.com/DavidHDev/react-bits/blob/main/src/demo/TextAnimations/RotatingTextDemo.jsx
The part you're looking for is here: