loading code fetching the highlighted snippet
Each tab renders its own underline motion.div, but they all share layoutId="underline". When one mounts as another unmounts, motion treats them as the same element and tweens between positions.
<motion.div layoutId="underline" /> when active. The shared layoutId tells motion these are the same element — it measures the outgoing
rect, mounts the new one, and tweens between them with a spring.AnimatePresence mode="wait": the previous emoji exits fully before the
next one enters, so the two never overlap during the swap.backgroundColor via animate={ backgroundColor: … } — no variants needed because each
cell decides its own state from selectedTab.