This repository contains an interactive and visually appealing button component built using React and Framer Motion. The "Fancy Button One" component demonstrates smooth animations on hover and click events, providing a modern and dynamic user experience.
-
Hover Animation:
- When the user hovers over the button, it scales up slightly.
- The background divs rotate dynamically to create a layered effect.
-
Click Animation:
- On click, the button and its background layers shrink and align perfectly, with all rotations resetting to
0.
- On click, the button and its background layers shrink and align perfectly, with all rotations resetting to
-
Responsive Design:
- The button and its layers are styled using Tailwind CSS, making it adaptable to different screen sizes and designs.
-
Spring Transition:
- All animations leverage Framer Motion's spring transitions, ensuring smooth and natural movement.
- React: For building the component's structure and managing states.
- Framer Motion: For handling complex and seamless animations.
- Tailwind CSS: For styling and responsive layout.
- The
motion.divandmotion.buttondetect hover events usingonHoverStartandonHoverEnd. - The button scales up (
scale: 1.1), and the background layers rotate slightly.
- The button detects click events using
onClickto toggle its state. - On click, the layers behind the button animate to align (
top: 17px,rotate: 0) while the entire structure shrinks (scale: 1).
- The component uses Tailwind CSS for consistent styling.
- Modify classes or animation parameters to fit your design.
-
Clone the repository:
git clone https://github.com/yourusername/fancy-button-one.git cd fancy-button-one -
Install dependencies:
npm install
-
Run the app:
npm start
-
Customize the component as needed in
FancyButtonOne.jsx.
Check out how the button responds to user interactions:
- Hover: Subtle scaling and rotation effects.
- Click: Shrinks and aligns layers for a seamless look.
.
├── src
│ ├── components
│ │ └── FancyButtonOne.jsx # Main component file
│ ├── App.js # Application entry point
│ ├── index.js # React DOM rendering
│ └── styles.css # Custom Tailwind CSS styles (optional)
├── package.json
├── README.md
└── ...
Contributions are welcome! Feel free to fork this repository and submit a pull request with your improvements or feature ideas.
This project is licensed under the MIT License.
Feel free to use, customize, and share this Fancy Button component for your projects! 🚀
