UI Patterns
Native-like

Navigation

Push and pop transitions between screens, tabs that keep their state, tapping the active tab, back without a browser, swipe back, and the collapsing large title.

A native app moves between screens in two ways. Tabs switch instantly between independent sections, and each remembers where you were. Push and pop go deeper and back inside a tab, with the new screen sliding in from the right and the old one sliding away. A web app that cross-fades every route, or resets the list you came from, gives itself away immediately.

Tap a row, go back, switch tabs, scroll, and tap the active tab:

Push and pop with view transitions

document.startViewTransition() snapshots the page, runs your DOM update, and animates from the old snapshot to the new one. Give the screen area a view-transition-name, and it gets its own pair of snapshots that you can animate separately from the rest of the page (the tab bar stays still):

.screen {
  view-transition-name: screen;
}
::view-transition-group(screen) {
  overflow: clip;
}

The direction comes from view transition types, passed when starting the transition and matched with :active-view-transition-type() (both Baseline since January 2026):

import { flushSync } from "react-dom";

function navigate(type: "push" | "pop", update: () => void) {
  if (!document.startViewTransition) return update();
  document.startViewTransition({
    update: () => flushSync(update),
    types: [type],
  });
}
html:active-view-transition-type(push) {
  &::view-transition-old(screen) {
    animation: 350ms cubic-bezier(0.2, 0, 0, 1) both out-left;
  }
  &::view-transition-new(screen) {
    animation: 350ms cubic-bezier(0.2, 0, 0, 1) both in-right;
  }
}
html:active-view-transition-type(pop) {
  &::view-transition-old(screen) {
    z-index: 1;
    animation: 350ms cubic-bezier(0.2, 0, 0, 1) both out-right;
  }
  &::view-transition-new(screen) {
    animation: 350ms cubic-bezier(0.2, 0, 0, 1) both in-left;
  }
}

@keyframes in-right {
  from {
    transform: translateX(100%);
  }
}
@keyframes out-left {
  to {
    transform: translateX(-30%);
    opacity: 0.7;
  }
}
@keyframes out-right {
  to {
    transform: translateX(100%);
  }
}
@keyframes in-left {
  from {
    transform: translateX(-30%);
    opacity: 0.7;
  }
}

The details that make it read as native:

  • The old screen moves too, only a third of the way, and dims. A new screen sliding over a still one looks like a modal, not a push.
  • On pop, the old screen goes on top (z-index: 1) — the screen you're leaving slides off and reveals the one underneath.
  • flushSync makes React apply the update inside the callback, so the "new" snapshot is the new screen and not the old one again.
  • Overflow clip on the group. The snapshots are drawn in a layer above the page, outside the container's own clipping, so without it the incoming screen shows outside its frame. If the container has rounded corners, give the group the same border-radius, or the square snapshots cover them for the length of the slide.

Two limits, both from how view transitions work. A document-wide transition "render[s] the entire page non-interactive until the transition is complete" (MDN), so a push can't be interrupted the way a native one can — see Motion; keep it around 350 ms. Element.startViewTransition() scopes the transition to one subtree and leaves the rest interactive, but it's still experimental.

Which way is back

In a real app the screens are URLs, and the browser's back button, the Android back gesture and your own back button should all pick the "pop" animation. The Navigation API (Baseline since January 2026) sees every navigation in one place, including history traversal:

navigation.addEventListener("navigate", (event) => {
  if (!event.canIntercept || event.hashChange || event.downloadRequest) return;
  const from = navigation.currentEntry?.index ?? -1;
  const to = event.destination.index;
  const type =
    event.navigationType === "traverse" && to < from ? "pop" : "push";

  event.intercept({
    async handler() {
      const content = await loadScreen(event.destination.url);
      await document.startViewTransition({
        update: () => render(content),
        types: [type],
      }).finished;
    },
  });
});

destination.index is -1 for a new entry, so anything that isn't a traversal to an earlier entry counts as a push. In Next.js the router owns navigation; React's <ViewTransition> component with addTransitionType is the matching tool there, but its documentation examples still use a canary build of React.

Tabs keep their state

Apple's guidelines describe tabs as letting "people quickly switch between sections of the view while preserving the current navigation state within each section". Switching is instant — no slide, because tabs aren't a hierarchy — and everything in the tab you left stays as it was: its stack of screens, its scroll position, a half-typed search. The tab bar itself stays visible on every screen, except under a modal. The demo keeps every tab mounted and hides the inactive ones:

<div inert={!active} className={active ? "" : "invisible"}>
  {/* the tab's screen stack */}
</div>

visibility: hidden keeps the layout, so scroll positions survive; unmounting the tab loses them. inert takes the hidden tab out of focus order and the accessibility tree. With a router, keep the per-tab state outside the route component (or use React's <Activity>), since a route change would unmount it.

Tapping the active tab

Tapping the tab you're already on pops it back to its first screen, and tapping again on the first screen scrolls to the top. This is a platform convention rather than a written rule — Apple's tab bar guidelines don't mention it — but iOS apps behave this way, and people use it as a "home" button for the section and the fastest way back from deep in a stack.

function onTab(tab: TabId) {
  if (tab !== active) return setActive(tab);
  if (stacks[tab].length > 1) return popToRoot(tab);
  scrollers.get(tab)?.scrollTo({
    top: 0,
    behavior: prefersReducedMotion() ? "auto" : "smooth",
  });
}

Back without a browser

In an installed app there's no browser back button. Android still has its system back gesture, which arrives as a normal history traversal — so the Navigation API code above animates it as a pop. On iOS, don't count on a gesture: every pushed screen needs a back button at the leading edge of its top bar. Apple's guidance is to "use the standard Back and Close buttons", prefer the standard symbol, and "don't use a text label that says Back" — a chevron, with an accessible name that says where it goes (aria-label="Back to Inbox").

Swipe back

On iOS most people go back by dragging the screen to the right: it follows the finger, the previous one slides in underneath, and letting go either finishes the pop or sends the screen back. UIKit has two versions:

  • interactivePopGestureRecognizer (iOS 7+) — "when a person swipes from the leading screen edge".
  • interactiveContentPopGestureRecognizer (iOS 26+) — "when a person initially pans horizontally in a leading to trailing direction in the view", recognized "on the entire content area".

The demo follows the newer one: drag a pushed screen to the right from anywhere on it.

This is the one navigation a view transition can't do. A view transition runs on a clock and can't be held, scrubbed or reversed; swipe-back is driven by the finger and then by a spring that starts at the finger's speed — the velocity hand-off from the Motion page. So the gesture moves the two screens itself:

const apply = (progress: number) => {
  top.style.transform = `translateX(${progress * width}px)`;
  previous.style.transform = `translateX(${-30 * (1 - progress)}%)`;
  previous.style.opacity = String(0.7 + 0.3 * progress);
};

const spring = createSpringValue(0, apply, {
  restDelta: 0.001,
  restSpeed: 0.01,
  onRest: (progress) => {
    if (progress === 1) flushSync(pop);
    resetStyles();
  },
});

// pointermove: decide once, then follow the finger
if (!active) {
  if (Math.abs(dx) < 10 && Math.abs(dy) < 10) return;
  if (dx <= 0 || Math.abs(dy) >= Math.abs(dx)) return cancel(); // let it scroll
  begin(); // capture the pointer, show the previous screen
}
spring.jump(startProgress + (x - startX) / width);

// pointerup: a flick goes its way, a slow release goes by position
const flick = Math.abs(velocity) > 1; // screen widths per second
const complete = flick ? velocity > 0 : spring.value > 0.5;
spring.to(complete ? 1 : 0, { velocity, duration: 0.35, bounce: 0 });

The details:

  • The first movement decides — threshold, then axis lock, the gesture arena's "declare the win". Nothing happens until the pointer has moved about 10 px; then a mostly-horizontal move to the right starts the gesture, and anything else is left alone. touch-action: pan-y on the screen keeps vertical scrolling native while horizontal moves reach your pointer handlers. A screen with its own horizontal content — a carousel, swipe-to-delete rows — has to claim those drags first; that's why UIKit kept the edge-only gesture alongside the new one.
  • Swallow the click that ends a drag (tactic 6). A drag that ends over a button or row would also fire its click; cancel it in the capture phase when the pointer moved.
  • Isolate each screen (isolation: isolate). The previous screen becomes visible as soon as the gesture starts, and without its own stacking context a z-index inside it — a sticky or overlaid bar — paints above the screen on top.
  • A flick decides by direction, a slow release by position. Past halfway and let go slowly, it closes; a quick flick either way wins regardless of position. Projecting "where would the finger carry it" sounds smarter, but a small backward wobble as the finger lifts is enough to send a screen that's 60% gone back again.
  • Measure speed at release, from the last ~100 ms before the finger lifts. Measuring from the last movement instead keeps a stale speed when the finger stops before lifting, and the screen flies off.
  • Pop without a view transition when the gesture finishes — the screens are already in place, so commit the state change with flushSync and only then clear the inline styles, or the old screen flashes back for a frame.
  • Let people catch it. Touching the screen while the spring is still running stops it and continues from the current position.
  • Keep the back button. The gesture is a shortcut; the button is how keyboard, switch-control and screen-reader users go back.

In Safari a swipe from the left edge is also the browser's own back gesture, and the two compete. Enable the custom one only in the installed app — check display-mode: standalone first (see Installed app) — and test on a device.

Large title

Apple: "Use a large title to help people stay oriented as they navigate and scroll. By default, a large title transitions to a standard title as people begin scrolling the content, and transitions back to large when people scroll to the top." On the web that's a scroll-driven animation, no JavaScript. The large title is ordinary content and scrolls away; the small title in the bar fades in over the same distance.

The bar must sit outside the scrolling list, laid over it, not position: sticky inside it. When the list overscrolls, the rubber-band bounce moves the scroller's whole content — a sticky bar bounces with it, while on iOS the bar stays put and only the content bounces. Since the bar is no longer a descendant of the scroller, it can't use scroll(nearest); name the scroll timeline instead, and widen its scope to the shared parent with timeline-scope:

<div className="list-screen">
  <div className="bar">
    <span className="bar-material" />
    <span className="small-title">Inbox</span>
  </div>
  <div className="list-scroller">
    <h2 className="large-title">Inbox</h2>
    {/* rows */}
  </div>
</div>
.list-screen {
  position: relative;
  timeline-scope: --list;
}
.bar {
  position: absolute;
  inset: 0 0 auto;
  z-index: 1;
  height: 44px;
}
.bar-material {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / 0.75);
  backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--border);
}
.list-scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding-top: 44px;
  scroll-timeline-name: --list;
}

@supports (timeline-scope: --list) {
  .bar-material,
  .small-title,
  .large-title {
    animation-timeline: --list;
    animation-fill-mode: both;
  }
  .bar-material {
    opacity: 0;
    animation-name: fade-in;
    animation-range: 0 16px;
  }
  .large-title {
    animation-name: fade-out;
    animation-range: 0 28px;
  }
  .small-title {
    opacity: 0;
    animation-name: rise;
    animation-timing-function: ease-out;
    animation-range: 18px 36px;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes fade-out {
  to {
    opacity: 0;
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

Three things move, each over its own stretch of scroll, which is what keeps it from reading as a single fade:

  1. The bar material — blur and hairline — is invisible at the top, where nothing is under the bar, and arrives in the first 16 px, as soon as content starts sliding beneath it.
  2. The large title fades out over the first 28 px as it slides up under the bar. Left at full opacity it shows through the blur as a grey smear.
  3. The small title rises 6 px into place from 18 to 36 px. The ranges overlap on purpose: without the overlap there's a moment with no title at all.

scroll-timeline-name, timeline-scope and animation-range are all Baseline since October 2026; outside @supports, older browsers show a plain bar with the small title from the start.

The opacity: 0 matters for short screens. When the list doesn't overflow, there's nothing to scroll, the timeline is inactive and the animation has no effect — so the element falls back to its own styles. Without the base opacity, a short list shows the title twice.

Reduced motion

The demo skips the view transition entirely when prefers-reduced-motion: reduce is set, and scrolls to the top without smoothing. The screens still change at once, which is what matters; the slide only explains where the new screen came from.

Sources

On this page