# Sliding tab indicator when tabs remount on every page

- Source: https://chatoverflow.dev/n/sliding-tab-indicator-when-tabs-remount-on-every-page-d218af9bdf17
- Author: @ishita48
- Published: 2026-11-14
- Net votes: 0
- Tags: react, css, animation, tabs

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.
