The large title from a navigation bar on iOS1: the big "Experiments" heading that shrinks into the bar as you scroll the list, and grows back when you scroll up. It isn't a header that switches state when you pass a threshold. There is no threshold, no class toggled and no transition. Every property is a function of how far the list has scrolled, so stopping halfway leaves it halfway, and scrolling back plays it in reverse.
I wanted to try Motion's useScroll hook, and I had been watching how my phone does this large title animation. I thought it was really cool. I built it together with an AI agent, and explained in words how it should work. The full code is at the end.
What went wrong first
The one number that had to be right was the overlap. I found this problem and explained it to the agent. If the large title finishes fading exactly where the compact one starts, there is a scroll position where neither is legible, and the bar reads as empty. Starting the compact title at 60% while the large one runs to 70% gives a short stretch where both are faint. That is the part that makes it read as one title moving up, rather than two titles swapping.
How it works
Motion's useScroll2 gives the list's scrollY as a motion value, and useTransform3 maps it onto everything else over the first 56px. The large title fades out over the first 70% of that distance and shrinks to 0.92, scaled from its bottom-left corner so it sinks into place rather than drifting toward the middle. The bar behind it goes from clear to a 16px blur with the saturation up at 180%, under a fill that reaches 75% opacity. Its hairline and the compact title arrive over the last 40%, and the compact title rises 6px as it fades in. I tuned the blur and the overlap by eye.
Pulling the list down past the top stretches the title up to 1.08, the way the rubber band does on iOS. Whether you see that depends on the browser reporting a negative scroll position while it overscrolls, and Chrome doesn't. It stops the list at 0, and the title stays put. The collapse itself works well in Chrome.
If you're about to build one
The compact title is hidden from screen readers, since it repeats the heading that is already in the list, so there is one heading to land on rather than two. If you prefer reduced motion, the titles only crossfade: nothing scales, stretches or slides, and the bar still blurs in, since that changes what you see rather than moving it.
I would use this to tune up mobile views.
The code
CollapsingHeader.tsx
tuning.ts
"use client"import { createContext, useContext } from "react"/*** The numbers the header runs on. The published component reads these defaults; `/lab` is the only* caller that replaces them, with DialKit.*/export interface CollapsingHeaderTuning {/** the scroll distance, in px, over which the large title hands over to the bar */collapse: number}export const COLLAPSING_HEADER_TUNING: CollapsingHeaderTuning = {collapse: 56,}const CollapsingHeaderTuningContext = createContext(COLLAPSING_HEADER_TUNING)export const CollapsingHeaderTuningProvider = CollapsingHeaderTuningContext.Providerexport function useCollapsingHeaderTuning() {return useContext(CollapsingHeaderTuningContext)}
References
- 1.Navigation bars · Human Interface Guidelines · Apple
- 2.useScroll · Motion
- 3.useTransform · Motion





