Image
ComponentsResponsive image components with fallbacks.
Live Functional Playground Interactive Hooks • useState
Interactive Preview
useState Active
Click element to toggle state
Motion Physics & Animation Showcase Framer Motion ✨
Motion Physics
✨
Hover to trigger spring elevation lift
Format:
Required Animation Library: framer-motion & lucide-react
Install this package in your project before importing the animated component.
npm i framer-motion lucide-react <img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Beautiful landscape" class="rounded-md object-cover h-64 w-full" / width="800" height="600"> <img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Beautiful landscape" className="rounded-md object-cover h-64 w-full" / width="800" height="600"> "use client";
import React, { useState } from "react";
interface ImageProps {
className?: string;
children?: React.ReactNode;
}
export default function Image({
className = "",
children,
}: ImageProps) {
const [isActive, setIsActive] = useState(false);
return (
<div
onClick={() => setIsActive(!isActive)}
className={`transition-all ${isActive ? "ring-2 ring-primary/30 rounded-xl" : ""} ${className}`}
>
<img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Beautiful landscape" className="rounded-md object-cover h-64 w-full" / width="800" height="600">
</div>
);
} "use client";
import React from "react";
import { motion } from "framer-motion";
export default function AnimatedImage() {
return (
<motion.div
initial={{ opacity: 0, scale: 0.96 }}
animate={{ opacity: 1, scale: 1 }}
whileHover={{ scale: 1.02 }}
whileTap={{ scale: 0.98 }}
transition={{ type: "spring", stiffness: 350, damping: 25 }}
className="cursor-pointer"
>
<img src="https://images.unsplash.com/photo-1588345921523-c2dcdb7f1dcd?w=800&dpr=2&q=80" alt="Beautiful landscape" className="rounded-md object-cover h-64 w-full" / width="800" height="600">
</motion.div>
);
}