vercel-react-view-transitions
Skill này làm gì
Skill này giúp thêm các chuyển động có hoạt ảnh giữa các màn hình và trạng thái trong ứng dụng React. Skill dành cho lập trình viên frontend muốn chuyển động tinh tế mà không cần mã hoạt ảnh nặng.
Khi nào nên dùng
- ✓Khi bạn muốn một hoạt ảnh mượt khi chuyển giữa các trang hoặc route.
- ✓Khi bạn muốn một phần tử chuyển động từ danh sách sang màn hình chi tiết.
- ✓Khi bạn muốn các mục trong danh sách có hoạt ảnh khi được sắp xếp lại hoặc thêm vào.
Liên kết skill
https://github.com/vercel-labs/agent-skills/blob/main/skills/react-view-transitions/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Thêm một chuyển động mượt khi người dùng nhấn vào thẻ sản phẩm và mở trang chi tiết.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill dùng một thành phần ViewTransition để chỉ định phần nào sẽ chuyển động, và bắt đầu thay đổi bằng các hook chuyển đổi. Kiểu dáng được đặt bằng class CSS, và trình duyệt không hỗ trợ sẽ bỏ qua hoạt ảnh một cách an toàn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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.
Choosing Animation Style
| Context | Animation | Why |
|---|---|---|
| Hierarchical navigation (list → detail) | Type-keyed nav-forward / nav-back |
Communicates spatial depth |
| Lateral navigation (tab-to-tab) | Bare <ViewTransition> (fade) or default="none" |
No depth to communicate |
| Suspense reveal | enter/exit string props |
Content arriving |
| Revalidation / background refresh | default="none" |
Silent — no animation needed |
Reserve directional slides for hierarchical navigation (list → detail) and ordered sequences (prev/next photo, carousel, paginated results). For ordered sequences, the direction communicates position: "next" slides from right, "previous" from left. Lateral/unordered navigation (tab-to-tab) should not use directional slides — it falsely implies spatial depth.
Availability
- Next.js: Do not install
react@canary— the App Router already bundles React canary internally.ViewTransitionworks out of the box.npm ls reactmay show a stable-looking version; this is expected. - Without Next.js: Use stable
reactandreact-dom19.3 or newer (ViewTransitionandaddTransitionTypebecame stable in React 19.3). Earlier stable React versions do not include these APIs. - Browser support: Chromium 125+ (React needs the v2 object form of
startViewTransition), Firefox 144+, Safari 18.2+. Graceful degradation on unsupported browsers.
Implementation Workflow
When adding view transitions to an existing app, follow references/implementation.md step by step. Start with the audit — do not skip it. Use references/css-recipes.md for the applicable CSS and adapt it to the app.
Core Concepts
The <ViewTransition> Component
import { ViewTransition } from 'react';
<ViewTransition>
<Component />
</ViewTransition>
React auto-assigns a unique view-transition-name and calls document.startViewTransition behind the scenes. Never call startViewTransition yourself.
Animation Triggers
| Trigger | When it fires |
|---|---|
| enter | <ViewTransition> first inserted during a Transition |
| exit | <ViewTransition> first removed during a Transition |
| update | DOM mutations inside a <ViewTransition>, or the boundary itself changing size/position due to an immediate sibling. With nested VTs, mutation applies to the innermost one |
| share | Named VT unmounts and another with same name mounts in the same Transition |
Only startTransition, useDeferredValue, or Suspense activate VTs. Regular setState does not animate.
Critical Placement Rule
<ViewTransition> only activates enter/exit if it appears before any DOM nodes:
// Works
<ViewTransition enter="auto" exit="auto">
<div>Content</div>
</ViewTransition>
// Broken — div wraps the VT, suppressing enter/exit
<div>
<ViewTransition enter="auto" exit="auto">
<div>Content</div>
</ViewTransition>
</div>
Styling with View Transition Classes
Props
Values: "auto" (browser cross-fade), "none" (disabled), "class-name" (custom CSS), or { [type]: value } for type-specific animations.
<ViewTransition default="none" enter="slide-in" exit="slide-out" share="morph" />
If default is "none", all trigge
Câu hỏi thường gặp
Trình duyệt cũ có bị lỗi không?
Không. Trình duyệt không hỗ trợ View Transition API sẽ bỏ qua hoạt ảnh một cách êm ái.
Mọi phần tử đều nên có hoạt ảnh không?
Không. Mỗi hoạt ảnh nên thể hiện một mối liên hệ rõ ràng, nếu không thì không nên thêm.
Kiểu dáng được kiểm soát thế nào?
Thông qua các class CSS và pseudo-element của view transition.
Chi tiết
Mô tả gốc của tác giả
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 bet
repo: vercel-labs/agent-skills
Độ phổ biến
- Sao GitHub
- 33k
- Vị trí xếp hạng
- #8432
- Giấy phép
- —
- Cập nhật
- 28/10/2026
Bình luận
- …
Thêm skill từ kho mã này
vercel-react-native-skills
33kCung cấp cho agent của bạn các thực hành tốt nhất cho ứng dụng React Native và Expo, gồm hiệu năng danh sách, hoạt ảnh, điều hướng và module gốc.
vercel-optimize
33kKiểm tra một dự án Vercel đã triển khai về các vấn đề chi phí và tốc độ, bắt đầu từ số liệu production, rồi xếp hạng các cách sửa dựa trên file và tài liệu đã xác minh.
Skill tương tự
angular-developer
280kGiúp agent của bạn viết code Angular và tư vấn cấu trúc dự án, hữu ích khi bắt đầu dự án mới hoặc cải thiện hiệu suất.
frontend-a11y
280kGiúp agent của bạn làm cho giao diện web dễ tiếp cận với mọi người. Đảm bảo website và ứng dụng hoạt động tốt với trình đọc màn hình và điều hướng bằng bàn phím.
frontend-patterns
280kGiúp agent của bạn áp dụng các mẫu hiện đại trong phát triển frontend. Tối ưu hiệu năng, quản lý trạng thái và tuân theo thực hành tốt nhất với React và Next.js.