Every state change the library makes is a React transition. That is what lets React keep old content on screen, and it is also what lets <ViewTransition> animate the change.
<ViewTransition> boundary in the tree is affected.addTransitionType. A <ViewTransition> can pick its animation by type, and CSS can match it with :active-view-transition-type().transition propEach part whose mount, unmount or content is driven by library state has a transition prop. When you pass it, the part renders a <ViewTransition> as the outermost node of its output; without it, the part renders no boundary at all. The value has exactly React's type: "auto", "none", a View Transition class, or a map from transition type to class. A string and a map do different things:
| `transition` | What animates |
|---|---|
a class ("fade", "auto") | this instance's own changes that the library dispatched (its open and close, its switch, its item opening, its action ending), and its own mount and unmount, whatever caused them, when the part is the top of what mounts or unmounts (Mount and unmount). Nothing else: not an unrelated transition, not another part of the same kind, not content that changes inside it |
"none" | nothing; the boundary stays, so you can switch to a class without a remount |
| a type map | React's rules, unchanged: each entry animates every commit that carries its type, on every part that has the map and that the commit reaches (Type maps) |
Under the hood the string is a type map keyed on an internal type that only this instance's dispatch adds. You never write that type, and its text is not API, but you may see it (fsui-i-…) in :active-view-transition-type() or in React's view transition events.
Treat transition as static. Changing it between undefined and a value remounts the part (development warns); switching between "none" and a class does not. Any value, "none" and a type map that does not match included, has a cost: when the part mounts or is revealed in a transition (a tab switch with keepMounted false or true, a part inside a dialog that opens), React starts a document view transition. The browser then cross-fades the whole page for 250 ms, and the next transition commit waits for it. A closed popup is the exception: it mounts in two steps and starts none (Closed popups).
Example: Tabs
Tabs.Panel takes transition, which animates the swap from one panel to the next. A class animates every switch of this Tabs; a type map picks a slide direction from the Tabs transition types (what else such a map names: Type maps):
<Tabs.Panel value="billing" transition="fade">...</Tabs.Panel>
<Tabs.Panel
value="billing"
transition={{ "fsui-tabs-next": "slide-left", "fsui-tabs-prev": "slide-right", default: "none" }}
>
...
</Tabs.Panel>::view-transition-old(.slide-left) { animation: 160ms ease-in both slide-out-left; }
::view-transition-new(.slide-left) { animation: 160ms ease-out both slide-in-right; }
@media (prefers-reduced-motion: reduce) {
::view-transition-group(*),
::view-transition-old(*),
::view-transition-new(*) { animation: none !important; }
}Every animation comes from your stylesheet, so reduced motion is yours to handle: when you write an animation (a view transition or plain CSS), add a prefers-reduced-motion rule like the one above.
If you want only your own named animations, you can opt out of the page cross-fade with the CSS below. It is optional and applies to every view transition on the page, including your router's. The last rule keeps clicks working, in Firefox, on content that is not animating (Input during a view transition).
::view-transition-old(root),
::view-transition-new(root) { animation: none; }
/* or: :root { view-transition-name: none; } */
::view-transition { pointer-events: none; }"Its own mount and unmount" follows React's rule for enter and exit. In a transition commit, React plays a boundary's enter or exit only when the boundary is the top of the content that is inserted or removed: no DOM element of that content sits above it. Components that render no element of their own (a function component, a Fragment) do not count. So a part with a string animates its own mount and unmount when it is inserted or removed itself, and not when a DOM element around it is inserted or removed in the same commit. To animate that, put your own <ViewTransition> around the outermost element that is inserted or removed. Like any boundary, it starts a document view transition when it mounts in a transition (the cost above).
A popup is usually placed long before it opens: a row's AlertDialog in a table that a Suspense boundary reveals, a Popover on a page a navigation mounts, a nested Dialog in the content of another. If its Popup has transition, its boundary would be placed in that transition and start a document view transition with nothing visible to animate. So the Popup of a Dialog, AlertDialog, Drawer, Popover, HoverCard, Menu (a submenu's too), Combobox and MultiSelect that is closed when it mounts on the client renders nothing in its mount commit, and its element inside the boundary in a synchronous commit right after, before the browser paints. React starts no view transition for that commit. The element is created once; every open after that is an update and animates as usual.
What you can see: the Popup's ref is still null in the layout effects and mount effects (useEffect(…, [])) of the component that renders it, and document.getElementById finds no popup there. Read the ref when you use it (in an event handler), or use a callback ref, which is called with the element once it exists. Not affected: a Popup that is open when it mounts (its mount is its enter and animates), a hydrated Popup, a Popup without transition, and JS-free mode. Still affected: a mounted Popup that a Suspense boundary hides behind its fallback and reveals again, or that an <Activity> hides and reveals: that reveal starts a view transition, unless a DOM element around the popup is revealed with it.
Example: Button
A Button with transition="fade" whose action removes it. The removal must commit in the action's transition: close sets the state before any await, or wraps it in startTransition after one (After an await); an urgent removal plays nothing.
{/* The Button is the top of what is removed: its exit plays. */}
{open && <Button transition="fade" action={close}>Close issue</Button>}
{/* The <div> is the top of what is removed: nothing plays. */}
{open && (
<div className="close-row">
<Button transition="fade" action={close}>Close issue</Button>
</div>
)}
{/* Your boundary is the top: the whole row fades out. */}
{open && (
<ViewTransition exit="fade" default="none">
<div className="close-row">
<Button action={close}>Close issue</Button>
</div>
</ViewTransition>
)}A string answers only the library's own dispatches, so a change you make yourself, a controlled open or value set in your own startTransition (a keyboard shortcut, a route), does not update the part through it, even if you add a type. A part that mounts, unmounts or is revealed by the change still animates through the string, when it is the top of what changes (above): a Tabs.Panel with the default keepMounted on a controlled switch, a part you render conditionally. For an update (every Popup, an Accordion.Item, a Collapsible.Root), pass a map keyed on the public type of the change and name the cause in your transition with addTransitionType. The map also matches the library's own dispatches, which carry the same types:
<Dialog.Popup transition={{ "fsui-dialog-open": "fade", "fsui-dialog-close": "fade", default: "none" }} />
startTransition(() => {
addTransitionType("fsui-dialog-open");
setOpen(true);
});Each component page lists its types in its Transition types section; they are public API for this. A type name of your own works too. A change with no transition to put a type in (a useDeferredValue render) needs a map with a default entry and its cost (below).
React starts a view transition only for a transition commit (What animates when). A controlled open or value that changes in an urgent update changes the trigger in a synchronous commit, which never animates, and the content region (a Panel, a Popup) in the deferred render that follows, and a pending action holds neither. That deferred commit carries no transition types, so a string transition does not animate it; a type map with a class on default does. (An uncontrolled part with no action prop also writes urgently, but it adds its types to its deferred commit, so it animates as in a transition: An uncontrolled component with no action prop.) Your own startTransition makes the update a transition only when the state lives in React. State read with useSyncExternalStore (a store outside React) stays urgent: React's documentation says that mutations to such a store cannot be marked as non-blocking transition updates. A router that keeps its state in such a store renders every navigation urgently, so a part controlled by the URL animates a change that comes from the router only through its deferred commit, which carries no reliable types.
TanStack Router (1.170, client-side rendering) reads its location, search params and matches through useSyncExternalStore. A Tabs controlled by a search param (Controlled by a router), with a type map on its Panels, behaves like this in Chromium and Firefox (measured with a router of the same shape: a useSyncExternalStore store that navigate writes, and a write outside any event for Back):
default animates the switch; a map keyed only on fsui-tabs-next / -prev animates nothing (and the view transition still has every cost of Input during a view transition).valueChangeAction, which calls navigate. The direction type may or may not reach the switch: with nothing else pending the view transition carried none, and while another action was pending it carried fsui-tabs-next. Do not rely on it.navigate in your own startTransition changes none of this.To animate the switch, mirror the search param into React state, let the Tabs read that state, and copy each new value into it in a transition that names the direction. Clicks, arrow keys, Back and Forward then all slide:
const order = ["overview", "comments", "activity"];
const { tab = "overview" } = route.useSearch();
const [shown, setShown] = useState(tab);
useEffect(() => {
if (tab === shown) return;
startTransition(() => {
addTransitionType(order.indexOf(tab) > order.indexOf(shown) ? "fsui-tabs-next" : "fsui-tabs-prev");
setShown(tab);
});
}, [tab]);
<Tabs.Root value={shown} valueChangeAction={(next) => navigate({ search: { tab: next } })}>
...
<Tabs.Panel value="comments" transition={{ "fsui-tabs-next": "slide-left", "fsui-tabs-prev": "slide-right", default: "none" }}>The switch is then a transition like any other: a pending action holds it, and the Panel shows the old tab until it commits. Without the mirror, leave transition off Panels that the router controls: it buys a view transition per click and animates nothing useful.
The router's own viewTransition option (defaultViewTransition on the router, with types) calls document.startViewTransition around the navigation itself; the transition prop and the fsui-* types play no part in it. Together with a Panel that has transition, a click starts two view transitions, and in Chromium the Panel's one can skip the router's (measured once in two clicks). Do not combine them.
Because a string names only its own instance, the items below an Accordion item that opens are not part of its animation: they cross-fade to their new place with the page's root cross-fade, or jump if you switched that off. To make them slide, name every Item with a map that uses "auto" (the browser's move and resize, no class of yours) and keep the string on the Panel, which animates only the item that changed:
const move = { "fsui-accordion-open": "auto", "fsui-accordion-close": "auto", default: "none" };
<Accordion.Item value="a" transition={move}>
<Accordion.Trigger>Shipping</Accordion.Trigger>
<Accordion.Panel transition="fade">...</Accordion.Panel>
</Accordion.Item>Every Item is then named in every open and close of the Accordion: the ones that moved travel, the others show nothing, and all of them take no clicks while it runs.
A map is passed to React as default unchanged, and React applies it to every part that has it and that the commit reaches. In react-dom 19.3 a commit reaches every boundary around something it changes, and every boundary that hangs off the changed path with no DOM element in between. So a Popup, a Collapsible.Root or a Button (their boundary is the top of the component) is reached by almost any commit near it, while a Tabs.Panel or an Accordion part (under the component's own element) is reached only by a change inside that element, or by one nested inside it:
"auto".default entry resolves in every other transition commit on the page, a useDeferredValue render and a Suspense retry included. { default: "fade" } on a mounted part, even a closed popup, turns every transition anywhere into a view transition of 250 ms or more, with the input costs below.default entry falls back to React's "auto", which has the same cost. So a map ends with default: "none", and so does the map of your own <ViewTransition> around content inside a part.Each dispatch adds fsui-<component> and, where the change has a direction or kind, fsui-<component>-<change> through addTransitionType. They are public API: key your type maps on them, add them yourself for a controlled change, and match them in CSS. The types of the parts that take transition:
| Part | Types of the change |
|---|---|
Dialog.Popup, AlertDialog.Popup | fsui-dialog-open, fsui-dialog-close |
Drawer.Popup | fsui-drawer-open, fsui-drawer-close |
Popover.Popup | fsui-popover-open, fsui-popover-close |
HoverCard.Popup | fsui-hover-card-open, fsui-hover-card-close |
Menu.Popup | fsui-menu-open, fsui-menu-close (a submenu's too: a map on a parent menu plays when its submenu opens; the string does not) |
Combobox.Popup | fsui-combobox-open, fsui-combobox-close (never fsui-combobox: every value dispatch carries it) |
MultiSelect.Popup | fsui-multi-select-open, fsui-multi-select-close |
NavigationMenu.Popup | fsui-navigation-menu-open, fsui-navigation-menu-close |
Tabs.Panel | fsui-tabs, fsui-tabs-next, fsui-tabs-prev (DOM order of the new tab relative to the committed one) |
Accordion.Item, Accordion.Panel | fsui-accordion-open, fsui-accordion-close |
Collapsible.Root, Collapsible.Panel | fsui-collapsible-open, fsui-collapsible-close |
Button | fsui-button (each action run) |
Every component page lists its own types, or says that it has none, in its Transition types section. Components whose state never changes in a transition add none: their commits are urgent, or their state belongs to the browser.
Match them in CSS with :active-view-transition-type(fsui-tabs-next). Types you add yourself with addTransitionType in the synchronous part of an action join the same transition.
Types are attached only to the commit that ends a dispatched action. A rollback after a rejection, or a controlled parent snapping the value back, carries no fsui-* type: neither animates with a string, and a type map needs a default entry (with its cost) if rollbacks should animate.
A view transition costs more than its animation. Measured in Chromium and Firefox with react-dom 19.3:
::view-transition { pointer-events: none } on whatever lies behind it. This also holds for an element you named in CSS (.main { view-transition-name: main }): the browser captures it in every view transition on the page, React's included, so the whole region ignores clicks and drags each time. Do not put a view-transition-name on a region that holds controls.::view-transition { pointer-events: none } restores it. That rule is needed for Firefox and does nothing for point 1.onChange, so the commit writes the old value back into a controlled input. Nothing in CSS prevents it, and a view transition in which nothing animates has the same window: do not start view transitions while the user acts (a string transition on a Combobox popup starts none after the open; a closed popup starts none when it mounts, Closed popups).So the mitigation is fewer and shorter view transitions: strings on the library's parts, maps that end with default: "none", no CSS view-transition-name on regions with controls, and short animations.
The lost input (point 3) applies to every view transition, including one the user did not cause. React starts a document view transition for a transition commit when a boundary (your own <ViewTransition> or a part with transition):
<Activity>, at the top of the inserted content (Mount and unmount), whatever its classes resolve to, "none" included (a closed popup excepted: Closed popups);"none" (Type maps).Moving content to another parent (a card that a save moves to another column, a row re-sorted into another group) is an unmount and a mount, so a boundary at the top of the moved content starts one even when every class is "none". When a background completion commits such a change in a transition (a save that finishes, a refetch, a Suspense retry) while the user types in a text field elsewhere, for example in a modal dialog, the character typed in that frame is lost. Two ways to avoid it:
setState outside startTransition. An urgent commit starts no view transition. The change does not animate, and if it suspends, the nearest Suspense fallback replaces the content. A data store read through useSyncExternalStore already commits this way (above), so its results start none.<ViewTransition> nor a part with transition. Key this on the dialog's open state, the one you pass to its Root, not on focus events: closing a <dialog> in Firefox fires no focusout, so a switch keyed on focus happens late, on a later click, and its remount can close the menu that click opened. Adding or removing a boundary remounts the content under it (DOM and state are lost), in the commit that opens the dialog and again in the one that closes it. So keep the dialog's Trigger, and the element that has focus when it opens, outside that content; otherwise the dialog returns focus to a removed element and focus ends on <body>. Open the dialog in an urgent update (Open your own controlled overlay urgently): in a transition, a pending action would hold the open, and removing a boundary that has an exit class would play that exit over the whole region.Up to 0.1.0-beta.3 a string transition was passed to React as default, so it answered every transition commit that reached the part. It now answers this instance's own dispatches and its own mount and unmount only. Type maps behave exactly as before. With a string, these no longer animate:
addTransitionType: use a map keyed on the public type plus addTransitionType (recipe). A part that mounts or is revealed by the change still animates.useDeferredValue render, a control inside an Accordion or Tabs panel. Wrap that content in your own <ViewTransition>, or use a map with a default entry and its cost.Menu.Popup when its submenu opens, an outer Tabs or Accordion around a nested one.Button whose content changes for any reason other than the end of its own action (a parent's transition changing its label).default entry if it should animate.In return, a mounted part with a string (a closed command palette in the app shell) no longer turns every transition on the page into a view transition.
React starts a view transition only for commits made entirely of transition lanes (a lane is React's priority class for an update; transitions have their own). The optimistic flip is a synchronous commit, so it never animates through <ViewTransition>. What to animate with depends on which value the part renders (see the three values):
| The part renders | Animate with |
|---|---|
optimistic state only (a trigger, a value control): no transition prop | a CSS transition on the data attribute |
| committed state (a content region) | the transition prop |
| the end of pending, or a rollback | the end of pending: the transition prop of the part around it when that part's own dispatch ends; a rollback (no type): a type map with a default entry, or your own <ViewTransition> |
| browser-owned state | CSS: @starting-style, transition-behavior: allow-discrete |
Example: Tabs
Tabs.Tab renders the optimistic selection: animate its colour with a CSS transition on [data-selected]. Tabs.Indicator follows the optimistic tab with CSS Anchor Positioning, so a plain CSS transition on its inset properties makes it slide on click and slide back on rollback. Tabs.Panel renders the committed selection: animate the swap with its transition prop. A Tab has no transition prop: a spinner rendered from its pending state disappears in the commit that ends the action, which your own <ViewTransition> around the Tab's content can animate.
A popup in the top layer can close two ways. A close the library performs (a part's close, a controlled open={false}) happens in a commit, so the popup's transition prop can animate it with a view transition in every engine (a controlled close with a map and the type, above). A dismissal happens in the browser before React hears about it, so only a CSS exit (@starting-style, transition-behavior: allow-discrete) can animate it; it is a fact, reported to onOpenChange in an urgent commit, which starts no view transition at all. Write both: the transition prop animates what the library does, CSS animates what the browser does, and the library's own show or hide never runs a CSS transition.
While a view transition runs, the library turns off the popup's CSS transitions for the moment of its own show or hide. Otherwise Chromium would keep a popup the library hides rendering through its CSS fade and capture it in the close's new snapshot as well as the old one (a double image), and the CSS enter would run under the view transition's enter. To do this, the library writes an inline transition: none !important on the popup for the length of that one call and then puts your inline transition back. A dismissal is never cut, so its CSS fade runs even when another view transition of the page starts during it (a dismissal while the library's own view transition runs fades inside that transition's new image). Only CSS transitions are cut: an exit written as a @keyframes animation on the closed state still runs during a library close, and Chromium captures it twice. Write the exit as a transition.
Example: Dialog
A Dialog with a CSS fade for Escape and a click outside, and a view transition for its Close parts:
<Dialog.Popup className="dialog" transition={{ "fsui-dialog-open": "pop", "fsui-dialog-close": "pop", default: "none" }}>.dialog { opacity: 0; transition: opacity 150ms, display 150ms allow-discrete, overlay 150ms allow-discrete; }
.dialog:open { opacity: 1; }
@starting-style { .dialog:open { opacity: 0; } }
::view-transition-new(.pop) { animation: 180ms ease-out both pop-in; }
::view-transition-old(.pop) { animation: 140ms ease-in both pop-out; }document.startViewTransition.flushSync: Enter on a closed Combobox. The value the form submits is committed with flushSync there, because the submission reads it in the same task, so a view transition that started in the frame before that key is skipped. The other writes that must reach the next paint (a popup's resolved data-side, a Field's error state after an edit) render in React's sync lane without flushSync, or skip flushSync while a view transition runs.<ViewTransition> renders no DOM and is safe in server-rendered trees; hydration is not a transition, so nothing animates on first paint.keepMounted) switch their <Activity> mode inside the library's transition, so nested <ViewTransition> boundaries get enter and exit animations.