THE PLAYGROUND · SCROLL & NAVIGATION
Hero Animation
A featured image expands into an immersive view.
Hero AnimationScroll & Navigation · A featured image expands into an immersive view.
CLICK
Explore the mountains 01 / LANDSCAPESA little escape.
1import { useState } from "react";2import { motion } from "motion/react";3 4const surface = { width: 100, height: 100, borderRadius: 16, background: "#b8ed79", display: "grid", placeItems: "center", color: "#141714" };5 6export default function HeroDemo() {7 const [open, setOpen] = useState(false);8 return <motion.div layout style={{...surface, width: open ? 320 : 150, height: open ? 240 : 110, overflow: "hidden", cursor: "pointer"}} transition={{ duration: 0.6, delay: 0, ease: "easeInOut" }} onClick={() => setOpen(v => !v)} role="button" tabIndex={0} onKeyDown={e => {if(e.key === "Enter") setOpen(v => !v);}}>9 <motion.div layout style={{width: "100%", height: "80%", background: "#71c7be"}}>Your image</motion.div>10 <motion.span layout>{open ? "Close detail" : "Open detail"}</motion.span>11 </motion.div>;12}Install: npm install motion. Keep the same image visible throughout the transition. This compact example illustrates the core technique; the styled playground contains additional presentation details.