Read the scroll container's `scrollTop` on every `scroll` event and map the range 0 to a threshold (usually 40–56px) into a progress value `p`. Use `p` to shrink the large title's `font-size`/`opacity` while growing the small title's — the one that lives inside the fixed nav bar — in the opposite direction.
The trick is keeping them as **the same text in two separate elements**: the large title scrolls with the content, the small one is pinned inside the nav bar. Crossfading between the two, instead of interpolating `font-size` directly, avoids the reflow cost of a font size that keeps changing.
iOS's canonical implementation is `UINavigationBar`'s `prefersLargeTitles`; Android's Material `CollapsingToolbarLayout` plays the same role. Both share the same priority — show the current screen's name big while you're just arriving, then get out of the way once scrolling signals you're moving on.
When to use
Use it at the entry point of a top-level tab — an inbox, settings. Screens you navigate deeper into typically start with the small title only.