view-transitions
它能做什么
这个技能使用浏览器的 View Transitions API,在页面状态和屏幕之间添加流畅的动画。它面向构建单页或多页网站的开发者。
适用场景
- ✓页面切换显得突兀,用户失去方向感的时候。
- ✓一张图片应平滑地展开为详情视图的时候。
- ✓检查网站是否使用了浏览器现在可以原生处理的动画库的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/view-transitions/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的应用切换页面时感觉很突兀。请帮我添加流畅的切换效果,但不引入大型动画库吗?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会用浏览器的过渡调用包裹页面切换,并为需要单独动画的元素命名。浏览器会在切换前后拍摄快照,然后在两者之间做动画。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use the View Transitions API for smooth page and component transitions
Jarring instant page changes are one of the most noticeable perceived- performance problems in web applications. Smooth transitions help users maintain context during navigation — they understand where they came from and where they are going. Previously, achieving this required complex JavaScript animation libraries; the View Transitions API delivers it natively at a fraction of the code cost.
Quick Reference
- Wrap DOM mutations in document.startViewTransition() for same-page transitions
- Add view-transition-name to elements that should animate individually (not the whole page)
- Use @starting-style and ::view-transition-* pseudo-elements to customise animations
- Enable cross-document transitions in CSS with @view-transition { navigation: auto }
Check
Check whether the site uses the View Transitions API or a JavaScript animation library for page and component transitions.
Fix
Implement view transitions using document.startViewTransition() for SPA route changes or @view-transition for MPA cross-document navigation.
Explain
Explain how the View Transitions API captures before/after snapshots and animates between them, and how view-transition-name enables shared-element transitions.
Code Review
Review transition implementation for missing prefers-reduced-motion guards, duplicate view-transition-name values (must be unique per snapshot), and transitions that may cause layout thrash in the old/new state.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/view-transitions
常见问题
这需要 JavaScript 库吗?
这个技能说,View Transitions API 内置于浏览器,因此省去了动画库所需的大部分代码。
过渡效果应该尊重减少动效设置吗?
应该。这个技能把缺少 prefers-reduced-motion 保护列为需要修复的问题。
view-transition-name 有什么用?
它让某个元素可以单独做动画,例如在两个页面之间共享的图片。
详情
作者的原始描述
Use when adding page transition animations, image expand/contract effects, shared-element transitions, or improving navigation UX in a single-page or multi-page application.
热度
- GitHub 星标
- 75k
- 排名
- #3077
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。