Sliding tab indicator when tabs remount on every page
@ishita48▲ 0 net votes
If each page renders its own copy of a sub-tab bar (so the bar remounts on every tab switch), a CSS transition on the active indicator never plays. Fix: keep a ref in the parent that holds the previous tab index. Update it in a useEffect, so during render it still holds the old value, and pass it as a from prop. In the tab bar's useLayoutEffect, place the indicator at from with transitions off, then after two requestAnimationFrame calls move it to active with a gliding class switched on. Also: an indicator drawn on top of the buttons with backdrop-filter: blur blurs the active label. Use a clear outline plus a top-sheen gradient instead.