Skip to content

View transitions

LayoutId animates elements that exist on both sides of a change. The browser's native View Transitions API handles the case where they do not: it snapshots the page before and after, then cross-fades the two. That makes it the right tool when a change is wholesale - a whole panel replaced, a route swapped - and LayoutId the right tool when one specific thing moves.

Wrapping a state change

BmotionViewTransition.StartAsync puts document.startViewTransition around a Blazor state change: your callback mutates state and calls StateHasChanged, and the browser handles the rest. Elements that carry a view-transition-name get their own snapshot pair and can be animated individually in CSS. Where the API is unsupported the state change simply applies without a transition - there is no fallback to write. StartAsync returns whether the browser played one, which the line under the panel reports.

BmotionViewTransitionOptions tunes a single call. Types tags the transition so a stylesheet can tell kinds of change apart with :active-view-transition-type(): with the box ticked, moving to a tab on the right is a "forward" transition and slides the panel left, and moving back is "backward" and slides it right. A browser without typed transitions plays the plain cross-fade. ReduceMotion overrides the library's reduced-motion policy for the call: null follows it (skipping the transition when motion is reduced), true always skips it, false always plays it - for a transition whose own CSS already honours prefers-reduced-motion.

Overview

A high-level tour. Switching tabs cross-fades this panel via the native View Transitions API - the panel is replaced outright, so there is no element for a FLIP to follow.

Last switch: none yet

Choosing between the two

They are complements, not competitors, and they can run in the same app on the same screen.

  • LayoutId (FLIP) - one element persists across the change and you want it to travel. Runs in C#, works in every browser Blazor does, and is interruptible mid-flight.
  • View transitions - the content is replaced wholesale and a cross-fade is the honest description of what happened. Costs almost no code, but the animation is the browser's and only runs where the API exists.
Bmotion 0 el · 0 active ▸
An unhandled error has occurred. Reload 🗙