StealThis .dev

Elastic Nav Indicator

A tab and underline navigation bar whose shared pill indicator slides between items and elastically squashes, stretches, and overshoots as it travels, adapting its width to every label with spring physics and full keyboard support.

Open in Lab
vanilla-js css
Targets: JS HTML

Code

The Elastic Nav Indicator is a single shared-element highlight that travels across a row of tabs, adapting its width to whatever label is active. Instead of a rigid slide, the indicator squashes along its direction of travel while it accelerates, stretches to bridge the gap between the old and new item, then overshoots and settles with a spring — the classic anticipation-and-follow-through you see in polished mobile navigation.

Under the hood a small spring integrator tracks a virtual position and width toward the target item. The travel velocity is mapped to a horizontal scale (squash) and a small vertical counter-scale, so the pill physically deforms in the direction it is moving. Two visual variants — a filled pill and a thin underline — share the exact same motion engine, proving the technique is purely presentational. Live controls let you tune stiffness, damping, and stretch intensity to feel the physics change in real time.

Interaction is fully keyboard driven: arrow keys move between tabs following the WAI-ARIA tablist pattern, Home and End jump to the ends, and focus is always visible. The component respects prefers-reduced-motion, collapsing the elastic travel into an instant, non-deforming move so motion-sensitive users still get a clear active state without the bounce.