前端开发

vercel-react-view-transitions

vercel-labs/agent-skills

Guide for implementing smooth, native-feeling animations using React's View Transition API (`<ViewTransition>` component, `addTransitionType`, and CSS view transition pseudo-elements). Use this skill whenever the user wants to add page transitions, animate route changes, create shared element animations, animate enter/exit of components, animate list reorder, implement directional (forward/back) navigation animations, or integrate view transitions in Next.js. Also use when the user mentions view transitions, `startViewTransition`, `ViewTransition`, transition types, or asks about animating between UI states in React without third-party animation libraries.

  • 17.4万 次安装
  • 3.3万 星标
  • 收录于

安装命令

npx skills add https://github.com/vercel-labs/agent-skills --skill vercel-react-view-transitions

要点

Native browser animations for React UI state changes using the View Transition API.

  • Declare animations with <ViewTransition> component; trigger with startTransition, useDeferredValue, or Suspense; control styling via CSS classes and pseudo-elements
  • Supports five animation patterns in priority order: shared elements (morphing), Suspense reveals, list identity (reorder), state changes (enter/exit), and route changes
  • Use addTransitionType to apply context-aware animations (e.g., directional slides for hierarchical navigation, fades for lateral tabs)
  • Works in Next.js App Router out of the box; requires react@canary for standalone React; gracefully degrades on unsupported browsers (Chromium 111+, Firefox 144+, Safari 18.2+)
  • Includes step-by-step implementation workflow, CSS animation recipes, and patterns for shared elements, list reorder, Suspense reveals, and directional navigation

SKILL.md

React View Transitions

Animate between UI states using the browser's native document.startViewTransition. Declare what with <ViewTransition>, trigger when with startTransition / useDeferredValue / Suspense, control how with CSS classes. Unsupported browsers skip animations gracefully.

When to Animate

Every <ViewTransition> should communicate a spatial relationship or continuity. If you can't articulate what it communicates, don't add it.

Implement all applicable patterns from this list, in this order:

Priority Pattern What it communicates
1 Shared element (name) "Same thing — going deeper"
2 Suspense reveal "Data loaded"
3 List identity (per-item key) "Same items, new arrangement"
4 State change (enter/exit) "Something appeared/disappeared"
5 Route change (page-level) "Going to a new place"

This is an implementation order, not a "pick one" list. Implement every pattern that fits the app. Only skip a pattern if the app has no use case for it.

React View Transitions

Animate between UI states using the browser's native document.startViewTransition. Declare what with <ViewTransition>, trigger when with startTransition / useDeferredValue / Suspense, control how with CSS classes. Unsupported browsers skip animations gracefully.

When to Animate

Every <ViewTransition> should communicate a spatial relationship or continuity. If you can't articulate what it communicates, don't add it.

Implement all applicable patterns from this list, in this order:

Priority Pattern What it communicates
1 Shared element (name) "Same thing — going deeper"
2 Suspense reveal "Data loaded"
3 List identity (per-item key) "Same items, new arrangement"
4 State change (enter/exit) "Something appeared/disappeared"
5 Route change (page-level) "Going to a new place"

This is an implementation order, not a "pick one" list. Implement every pattern that fits the app. Only skip a pattern if the app has no use case for it.