loading code fetching the highlighted snippet
A pink indicator slides between tabs on every click. Only the active tab renders one; sharing a layoutId lets motion animate the indicator across tab boundaries instead of mount-unmount-flash.
<li>. As selectedTab changes, the old indicator unmounts and the new one mounts
— sharing layoutId="selected-indicator" tells motion to animate from the
old position to the new one instead of fading out / in.<AnimatePresence> wraps the conditional render so motion gets a chance
to coordinate the handoff. Without it the indicator would still animate position, but
the mount/unmount lifecycle wouldn't have a clean exit window.whileTap for press feedback
and whileFocus for keyboard navigation. Plain object form on both; nothing
fancier needed.