Components
SpinningBoxText: Dynamic 3D Text Animation The SpinningBoxText component presents a captivating and interactive way to showcase a sequence of words or concepts. It features a central 3D spinning box that dynamically cycles through different words, creating a memorable visual effect that can highlight core values, processes, or key features.
What It Is This React component displays the phrase "As simple as" followed by a three-dimensional box that continuously rotates along its X-axis. As it spins, different faces of the box reveal distinct words, creating a seamless and engaging animation. This component is perfect for drawing attention to a concise message or a step-by-step process in a visually striking manner.
Key Features 3D Spinning Word Box: The core of the component is the SpinningBox sub-component, which simulates a 3D cube. It's designed to reveal four different words (front, bottom, back, top) as it rotates. The rotation uses a custom framer-motion animation sequence (rotateX with times array) to create a distinctive, impactful spin with pauses on each face. Customizable Content: You can easily define the words displayed on each visible face of the spinning box by passing front, bottom, back, and top props to the SpinningBox component. The default example demonstrates this with "Learn," "Earn," "Grow," and "Repeat." Engaging Animation: The framer-motion library is used to control the complex 3D rotation, ensuring smooth and performant transitions. The ease: "backInOut" transition creates a satisfying "bouncy" effect as the box settles on each word. The animation runs infinitely, providing a continuous loop of your chosen messages. Responsive Design: The component adapts its layout for different screen sizes, arranging the text and spinning box in a row on larger screens and stacking them vertically on smaller ones. Font sizes are also adjusted for optimal readability. Styling: Uses a bold, uppercase font for the words inside the box for high visibility. The box itself is styled with a distinct indigo background and border, making it stand out. Why It's Cool for Developers This component is an excellent demonstration of:
Advanced framer-motion Animations: It showcases how to implement complex 3D transformations (rotateX, transformStyle, transformOrigin) and orchestrate animation sequences using the times property for precise timing. Creating 3D Effects with CSS and Motion: It effectively uses CSS transform properties in conjunction with framer-motion to create a convincing 3D object from flat HTML elements. Reusable UI Components: The SpinningBox is a modular and reusable sub-component, allowing for easy integration into various parts of an application. Dynamic Content Display: It provides a creative solution for cycling through important keywords or short phrases without needing a full carousel or slider.
Loading preview...
import SpinningBoxText from "@/components/ui/spinning-box";
const DemoOne = () => {
return <SpinningBoxText />;
};
export { DemoOne };