remold/ui

useViewTransition

Run a change through the browser's View Transitions API, with Remold pairing the elements.

Usage

const { ref, animate } = useViewTransition();

<main ref={ref}>
  <button onClick={() => animate(() => setPage("detail"))}>Open</button>
</main>;

Best for large, route-sized changes, which the browser animates off the main thread. View transitions can't be interrupted, so it falls back to useRemold where the API is missing, when reduced motion is on, or for very large pages.

Options

Prop

Type

Returns

Prop

Type

On this page