Ask Your Question
0

How to create clickable links with blinking animation using Framer Motion?

asked 2022-05-15 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-29 11:00:00 +0000

nofretete gravatar image

To create clickable links with blinking animation using Framer Motion, you can follow these steps:

  1. Import the motion component from Framer Motion library:

    import { motion } from "framer-motion";
    
  2. Create a motion anchor tag by wrapping it with motion component:

    const Link = motion.a;
    
  3. Set the initial properties for the link component with a variant:

    const linkVariants = {
     initial: {
       opacity: 0.5,
     },
     hover: {
       opacity: 1,
       transition: { duration: 0.5 }
     }
    };
    
  4. Add a blinking animation to the link component with another variant:

    const linkBlink = {
     initial: {
       opacity: 1,
     },
     animate: {
       opacity: 0.5,
       transition: { duration: 0.5, repeat: Infinity }
     }
    };
    
  5. Combine both variants together in link component:

    <Link
     href="/"
     className="link"
     variants={linkVariants}
     initial="initial"
     whileHover="hover"
     animate="animate"
    >
     Click me!
    </Link>
    
  6. Style the link component with CSS:

    .link {
     font-size: 18px;
     color: red;
     text-decoration: none;
     margin: 10px;
    }
    

With these steps, you have created a clickable link with a blinking animation using Framer Motion.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-15 11:00:00 +0000

Seen: 13 times

Last updated: Jun 29 '21