Icon Wheel
The IconWheel brings your favorite icons to life, spinning endlessly in a mesmerizing circular motion. Whether showcasing tech stacks, skills, or fun graphics, this component keeps things dynamic and engaging. Plus, with smooth hover effects and responsive resizing, itβs the perfect way to add some interactive flair to your UI. Let your icons orbit in style! β¨π
Preview
Follow below steps ππ»
Install dependencies
1npm i framer-motion
Component
Create a file icon-wheel.tsx in your components folder and paste this code
1'use client';23import React, { useEffect, useState } from 'react';4import { motion } from 'framer-motion';5import Image from 'next/image';67type IconWheelProps = {8icons: Array<string>;9};1011const IconWheel = ({ icons }: IconWheelProps) => {12const [radius, setRadius] = useState(200); // Adjust based on the container size13const centerX = 32; // Center of the wheel (half of the container width)14const centerY = 32; // Center of the wheel (half of the container height)15const angleStep = (2 * Math.PI) / icons.length; // Angle between each item1617useEffect(() => {18window.addEventListener('resize', () => {19if (window.innerWidth < 500) setRadius(100);20else setRadius(200);21});22}, []);2324return (25<motion.div26initial={{27opacity: 028}}29whileInView={{30opacity: 1,31transition: {32delay: 0.5,33duration: 0.534}35}}36viewport={{37once: true38}}39animate={{40rotateZ: 360,41transition: { duration: 10, ease: 'linear', repeat: Infinity }42}}43className="relative h-[250px] sm:h-[500px] w-[250px] sm:w-[500px] flex items-center justify-center my-10"44>45{icons.map((url, i) => {46const angle = i * angleStep; // Angle for the current icon47const x = centerX + radius * Math.cos(angle) - 32; // Subtract half of img width (64/2)48const y = centerY + radius * Math.sin(angle) - 32; // Subtract half of img height (64/2)4950return (51<motion.div52animate={{53rotateZ: -360,54transition: { duration: 10, ease: 'linear', repeat: Infinity }55}}56whileHover={{57scale: 1.258}}59key={`iconwheel${i}`}60initial={{ x, y }}61className="absolute rounded-full"62>63<Image src={url} height={64} width={64} alt="iconwheel" />64</motion.div>65);66})}67</motion.div>68);69};7071export default IconWheel;
Usage
1<IconWheel2icons={[3'/css.png',4'/framermotion.png',5'/javascript.png',6'/nextjs.png',7'/nodejs.png',8'/reactjs.png',9'/tailwindcss.png',10'/typescript.png'11]}12/>
βοΈ Got a question or feedback?
Feel free to reach out!