Please use Desktop to view and interact with components
Microinteractions300msspring
Heart Favorite
Animated heart icon for like/favorite actions
iconfavoritelike
Useto navigate between components
Preview
Code
TypeScript + React
'use client'
import { motion } from 'framer-motion'
import { Heart } from 'lucide-react'
import { useState } from 'react'
export function HeartFavorite() {
const [isLiked, setIsLiked] = useState(false)
return (
<motion.button
onClick={() => setIsLiked(!isLiked)}
whileTap={{ scale: 0.9 }}
className="rounded-full p-4 transition-colors hover:bg-gray-100 dark:hover:bg-gray-800"
>
<motion.div
animate={{
scale: isLiked ? [1, 1.3, 1] : 1,
}}
transition={{
duration: 0.3,
ease: 'easeInOut',
}}
>
<Heart
className={`h-8 w-8 transition-colors ${
isLiked
? 'fill-red-500 text-red-500'
: 'text-gray-400'
}`}
/>
</motion.div>
</motion.button>
)
}
How to Use
- 1Install Framer Motion:
npm install framer-motion - 2Copy the code from above
- 3Paste it into your project and customize as needed
- 4Colors are customizable via Tailwind CSS classes. The default theme uses dark mode colors defined in your globals.css file