Communitygithub.com

React View Transitions - ネイティブUIアニメーションガイド

ReactのView Transition API(`<ViewTransition>`コンポーネント、`addTransitionType`、CSS疑似要素)を使用して、スムーズでネイティブ感のあるアニメーションを実装するためのガイドです。

React View Transitions - ネイティブUIアニメーションガイド とは?

このスキルは、ReactアプリケーションにおいてブラウザネイティブのView Transition API(`document.startViewTransition`)を活用し、UI状態間のアニメーションを実装するための包括的なガイドです。主な構成要素は、`<ViewTransition>`コンポーネント(アニメーション対象の宣言)、`startTransition`/`useDeferredValue`/`Suspense`(トリガーの制御)、そしてCSS疑似要素(アニメーションの詳細な制御)です。サポート対象プラットフォームはNext.js(App Router標準搭載)とそれ以外のReact環境(`react@canary`が必要)で、Chromium 111+、Firefox 144+、Safari 18.2+以降のブラウザで動作します。非対応ブラウザでは自動的にアニメーションがスキップされ、グレースフルデグラデーションが行われます。主なアニメーションパターンとして、共有要素トランジション(`name`プロパティ)、Suspenseによる表示、リストの並び替え(`key`)、要素のenter/exit、ルート変更の5つが定義されており、それぞれが「同じ要素が深くなる」「データが読み込まれた」「同じアイテムが新しい配置に」「何かが出現/消滅した」「新しい場所に行く」といった空間的関係や連続性を視覚的に伝えます。また、`addTransitionType`を用いてトランジションにタイプを付与し、ナビゲーションの方向(前進/後退)に応じて異なるアニメーションを適用することが可能です。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/xzedm/clipplic-landing/tree/HEAD/.agents/skills/vercel-react-view-transitions

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

プレビュー

スキル README より

React View Transitions - ネイティブUIアニメーションガイド preview
React View Transitions - ネイティブUIアニメーションガイド preview

ドキュメント

React View Transitions (React画面遷移アニメーション)

ブラウザネイティブの document.startViewTransition を使用して、UI状態間のアニメーションを実現します。アニメーション対象を <ViewTransition> で宣言し、startTransition / useDeferredValue / Suspense で発火タイミングを制御し、CSSクラスでアニメーションの詳細を指定します。非対応ブラウザではアニメーションは自動的にスキップされ、問題なく動作します。

アニメーションを適用するタイミング

すべての <ViewTransition> は、空間的な関係性や連続性を伝えるために使用する必要があります。「このアニメーションは何を伝えるのか」を明確に説明できない場合は、追加すべきではありません。

以下のリストから、該当するすべてのパターン をこの優先順位で実装してください:

優先度パターン伝える内容
1共有要素 (name)「同じものが、より深い階層へ」
2Suspense表示「データが読み込まれた」
3リスト識別 (要素ごとの key)「同じアイテム、新しい配置」
4状態変化 (enter/exit)「何かが現れた/消えた」
5ルート変更 (レイアウトレベル)「新しい場所へ移動」

これは「1つを選ぶ」リストではなく、実装順序を示しています。アプリに適合するすべてのパターンを実装してください。アプリにユースケースがない場合のみ、そのパターンをスキップします。

アニメーションスタイルの選択

コンテキストアニメーション理由
階層的ナビゲーション(リスト→詳細)タイプ指定 nav-forward / nav-back空間的な奥行きを伝える
横方向ナビゲーション(タブ切り替え)ベアな <ViewTransition> (フェード) または default="none"奥行きを伝える必要がない
Suspense表示enter/exit 文字列プロップコンテンツの到着
再検証 / バックグラウンド更新default="none"静かに、アニメーション不要

方向性のあるスライドは、階層的ナビゲーション(リスト→詳細)と順序付けられたシーケンス(前/次の写真、カルーセル、ページネーション結果)に限定してください。順序付けられたシーケンスでは、方向が位置を伝えます:「次」は右からスライド、「前」は左からスライドします。横方向/順序のないナビゲーション(タブ切り替え)には方向性のあるスライドを使用しないでください。空間的な奥行きを誤って伝えてしまいます。


利用可否

  • Next.js: react@canary をインストールしないでください。App Routerには既にReactのcanaryビルドがバンドルされています。ViewTransition はそのまま動作します。npm ls react で安定版のように見えるバージョンが表示される場合がありますが、これは正常です。
  • Next.js以外: react@canary react-dom@canary をインストールしてください(ViewTransition は安定版Reactには含まれていません)。
  • ブラウザサポート: Chromium 111以上、Firefox 144以上、Safari 18.2以上。非対応ブラウザではグレースフルに機能が低下します。

実装ワークフロー

既存のアプリにビュートランジションを追加する場合は、references/implementation.md をステップバイステップで順に従ってください。 監査(audit)から始め、スキップしないでください。CSSレシピは references/css-recipes.md からコピーしてグローバルスタイルシートに追加し、独自のアニメーションCSSは記述しないでください。


中核概念

<ViewTransition> コンポーネント

import { ViewTransition } from 'react';

<ViewTransition>
  <Component />
</ViewTransition>

Reactが自動で一意の view-transition-name を割り当て、内部で document.startViewTransition を呼び出します。startViewTransition を自分で呼び出さないでください。

アニメーションの発火トリガー

トリガー発火タイミング
enterトランジション中に <ViewTransition> が初めて挿入されたとき
exitトランジション中に <ViewTransition> が初めて削除されたとき
update<ViewTransition> 内部のDOMが変更されたとき。ネストされたVTの場合、最も内側のVTに適用される
share名前付きVTがアンマウントされ、同じ name を持つ別のVTが同じトランジション内でマウントされたとき

VTを有効化するのは startTransition、useDeferredValue、Suspense のみです。通常の setState ではアニメーションは発生しません。

配置ルール(重要)

<ViewTransition> は、すべてのDOMノードより前に配置 されている場合にのみ enter/exit を有効化します:

// 動作する
<ViewTransition enter="auto" exit="auto">
  <div>コンテンツ</div>
</ViewTransition>

// 動作しない:divがVTをラップしているため、enter/exitが抑制される
<div>
  <ViewTransition enter="auto" exit="auto">
    <div>コンテンツ</div>
  </ViewTransition>
</div>

ビュートランジションクラスを使ったスタイリング

プロップ

値: "auto"(ブラウザのクロスフェード)、"none"(無効)、"class-name"(カスタムCSS)、または { [type]: value }(タイプ固有のアニメーション用)。

<ViewTransition default="none" enter="slide-in" exit="slide-out" share="morph" />

default が "none" の場合、明示的にリストされたトリガー以外はすべてオフになります。

CSS疑似要素

  • ::view-transition-old(.class): 遷移前のスナップショット
  • ::view-transition-new(.class): 遷移後のスナップショット
  • ::view-transition-group(.class): コンテナ
  • ::view-transition-image-pair(.class): old + new のペア

すぐに使えるアニメーションレシピは references/css-recipes.md を参照してください。


トランジションタイプ

トランジションに addTransitionType でタグを付けることで、VTがコンテキストに応じて異なるアニメーションを選択できるようになります。複数回呼び出してタイプを積み重ねることができ、ツリー内の異なるVTが異なるタイプに反応します:

startTransition(() => {
  addTransitionType('nav-forward');
  addTransitionType('select-item');
  router.push('/detail/1');
});

タイプをCSSクラスにマッピングするにはオブジェクトを渡します。enter、exit、および share で使用できます:

<ViewTransition
  enter={{ 'nav-forward': 'slide-from-right', 'nav-back': 'slide-from-left', default: 'none' }}
  exit={{ 'nav-forward': 'slide-to-left', 'nav-back': 'slide-to-right', default: 'none' }}
  share={{ 'nav-forward': 'morph-forward', 'nav-back': 'morph-back', default: 'morph' }}
  default="none"
>
  <Page />
</ViewTransition>

enter と exit は対称である必要はありません。例えば、フェードインして方向性のあるスライドアウト:

<ViewTransition
  enter={{ 'nav-forward': 'fade-in', 'nav-back': 'fade-in', default: 'none' }}
  exit={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
  default="none"
>

TypeScript: ViewTransitionClassPerType はオブジェクト内に default キーを必須とします。

複数ページのアプリでは、タイプキー付きVTを再利用可能なラッパーに抽出します:

export function DirectionalTransition({ children }: { children: React.ReactNode }) {
  return (
    <ViewTransition
      enter={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
      exit={{ 'nav-forward': 'nav-forward', 'nav-back': 'nav-back', default: 'none' }}
      default="none"
    >
      {children}
    </ViewTransition>
  );
}

router.back() とブラウザの戻るボタン

router.back() およびブラウザの戻る/進むボタンは、ビュートランジションをトリガーしません(popstate は同期的で、startViewTransition と互換性がありません)。代わりに router.push() に明示的なURLを指定して使用してください。

タイプとSuspense

タイプはナビゲーション中に利用できますが、その後のSuspense表示中は利用できません(別個のトランジションであり、タイプは引き継がれません)。ページレベルのenter/exitにはタイプマップを使用し、Suspense表示には単純な文字列プロップを使用してください。


共有要素トランジション

2つのVTが同じ name を持ち、片方がアンマウントされもう片方がマウントされると、共有要素のモーフィングが発生します:

<ViewTransition name="hero-image">
  <img src="/thumb.jpg" onClick={() => startTransition(() => onSelect())} />
</ViewTransition>

// 別のビューで、同じname
<ViewTransition name="hero-image">
  <img src="/full.jpg" />
</ViewTransition>
  • 特定の name を持つVTは同時に1つしかマウントできません。一意の名前を使用してください(photo-${id})。再利用可能なコンポーネントに注意:名前付きVTを持つコンポーネントがモーダル/ポップオーバーおよび ページの両方でレンダリングされると、両方が同時にマウントされモーフィングが破綻します。名前を条件付きにする(プロップ経由)か、名前付きVTを共有コンポーネントから特定のコンシューマーに移動してください。
  • share は enter/exit よりも優先されます。各ナビゲーションパスを考慮してください:一致するペアが形成されない場合(例:遷移先ページに同じ名前がない場合)、代わりに enter/exit が発火します。そのパスにおけるフォールバックアニメーションが必要かどうかを検討してください。
  • 共有モーフを含むページでフェードアウトのexitを使用しないでください。代わりに方向性のあるスライドを使用してください。

一般的なパターン

Enter/Exit

{show && (
  <ViewTransition enter="fade-in" exit="fade-out"><Panel /></ViewTransition>
)}

リスト並び替え

{items.map(item => (
  <ViewTransition key={item.id}><ItemCard item={item} /></ViewTransition>
))}

startTransition 内でトリガーします。リストとVTの間にラッパー <div> を置かないでください。

リスト識別と共有要素の組み合わせ

共有要素とリスト識別は独立した関心事であり、混同しないでください。リストアイテムに共有要素(例:詳細ビューにモーフィングする画像)が含まれる場合は、2つのネストされた <ViewTransition> バウンダリーを使用します:

{items.map(item => (
  <ViewTransition key={item.id}>                                      {/* リスト識別 */}
    <Link href={`/items/${item.id}`}>
      <ViewTransition name={`item-image-${item.id}`} share="morph">   {/* 共有要素 */}
        <Image src={item.image} />
      </ViewTransition>
      <p>{item.name}</p>
    </Link>
  </ViewTransition>
))}

外側のVTはリストの並び替え/enterアニメーションを処理します。内側のVTはルート間の共有要素モーフィングを処理します。どちらかのレイヤーが欠けていると、そのアニメーションは静かに実行されません。

key による強制再Enter

<ViewTransition key={searchParams.toString()} enter="slide-up" default="none">
  <ResultsGrid />
</ViewTransition>

注意: <Suspense> をラップする場合、key を変更するとバウンダリーが再マウントされ、データが再取得されます。

Suspenseのフォールバックからコンテンツへ

シンプルなクロスフェード:

<ViewTransition>
  <Suspense fallback={<Skeleton />}><Content /></Suspense>
</ViewTransition>

方向性のある表示:

<Suspense fallback={<ViewTransition exit="slide-down"><Skeleton /></ViewTransition>}>
  <ViewTransition enter="slide-up" default="none"><Content /></ViewTransition>
</Suspense>

より多くのパターンについては references/patterns.md を参照してください。


複数のVTの相互作用

トリガーにマッチするすべてのVTは、単一の document.startViewTransition 内で同時に発火します。異なるトランジション(ナビゲーション vs 後続のSuspense解決)内のVTは競合しません。

default="none" を積極的に使用する

これがないと、すべてのVTがすべてのトランジションでブラウザのクロスフェードを発火します。Suspense解決、useDeferredValue 更新、バックグラウンド再検証など。常に default="none" を使用し、必要なトリガーのみを明示的に有効にしてください。

2つのパターンは共存する

パターンA. 方向性スライド: 各ページのタイプキー付きVT。ナビゲーション中に発火します。 パターンB. Suspense表示: 単純な文字列プロップ。データ読み込み時に発火します(タイプなし)。

これらは異なるタイミングで発火するため共存できます。両方に default="none" を設定することで相互干渉を防ぎます。常に enter と exit をペアで指定してください。方向性VTはページコンポーネントに配置し、レイアウトには配置しないでください。

ネストされたVTの制限

親VTがexitするとき、その内部のネストされたVTは自身のenter/exitを発火しません。最も外側のVTのみがアニメーションします。現在のところ、ページナビゲーション中にアイテムごとにずらしたアニメーションを実現することはできません。実験的なオプトイン修正については react#36135 を参照してください。


Next.js 連携

Next.jsのセットアップ(experimental.viewTransition フラグ、next/link の transitionTypes プロップ、App Routerパターン、サーバーコンポーネント)については、references/nextjs.md を参照してください。


アクセシビリティ

references/css-recipes.md から「動きの低減」(reduced motion)CSSを必ずグローバルスタイルシートに追加してください。


参照ファイル

  • references/implementation.md: ステップバイステップの実装ワークフロー。
  • references/patterns.md: パターン、アニメーションのタイミング、イベントAPI、トラブルシューティング。
  • references/css-recipes.md: すぐに使えるCSSアニメーションレシピ。
  • references/nextjs.md: Next.js App Router パターンとサーバーコンポーネントの詳細。

完全な統合ドキュメント

すべての参照ファイルを展開した完全なガイドについては:AGENTS.md

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

xzedm/clipplic-landing

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.

xzedm/clipplic-landing

Material Design 3 and Android platform guidelines. Use when building Android apps with Jetpack Compose or XML layouts, implementing Material You, navigation, or accessibility. Triggers on tasks involving Android UI, Compose components, dynamic color, or Material Design compliance.

xzedm/clipplic-landing

Apple's approach to interface design and fluid, physical motion, translated for the web. Use when building or reviewing gesture-driven UI, spring animations, drag/swipe/sheet interactions, momentum and interruptible transitions, translucent materials and depth, typography (optical sizing, tracking, leading), reduced-motion, or the design foundations (feedback, spatial consistency, restraint) behind Apple-style interfaces.

xzedm/clipplic-landing

Design iOS apps following Apple's Human Interface Guidelines. Generate native components, validate designs, and ensure accessibility compliance for iPhone, iPad, and Apple Watch.

xzedm/clipplic-landing

Redesign mobile app UI to feel unmistakably Apple-like, iOS-forward, and native. Use this skill when building iOS apps, applying Apple Human Interface Guidelines, or creating native-feeling mobile interfaces with SF Pro typography, translucency, and system-like components.

xzedm/clipplic-landing

Accessibility engineering for product interfaces, from focus states and keyboard support to ARIA, forms, and screen readers. Use when building or reviewing UI components, modals, menus, forms, custom widgets, or when the user says "make this accessible" or reports keyboard or screen-reader issues. Triggers on accessibility, a11y, WCAG, aria, focus ring, focus-visible, focus trap, keyboard navigation, tab order, tabindex, screen reader, sr-only, aria-live, alt text, hit area, touch target, prefers-reduced-motion, autoplay, toast duration, skip link, semantic HTML, aria-label, form errors, disabled buttons, "not keyboard accessible".

xzedm/clipplic-landing

OKLCH color space and color usage for web projects. Convert hex/rgb/hsl to oklch, generate palettes, check contrast, handle gamut boundaries, theme with Tailwind v4, and apply color with meaning. Triggers on oklch, color conversion, palette generation, contrast ratio, gamut, display p3, design tokens, semantic color tokens, hue drift, chroma, dark mode colors, accent color, color meaning, light and dark appearance, increased contrast.

xzedm/clipplic-landing

Layout structure for web interfaces, from grouping and alignment to reading order, progressive disclosure, and adaptive breakpoints. Use when structuring a page or component, spacing or aligning controls, deciding what collapses at small sizes, handling RTL layout direction, or reviewing frontend code for layout. Triggers on layout, spacing, alignment, grouping, negative space, whitespace, visual hierarchy, reading order, progressive disclosure, breakpoints, responsive layout, container queries, safe area, full-bleed, edge-to-edge, layout margins, RTL layout, logical properties.

xzedm/clipplic-landing

Web typography from choosing fonts to spacing, wrapping and accessibility. Use when picking or pairing typefaces, configuring variable fonts or OpenType features, setting up a type scale, checking heading hierarchy, styling text in components, truncating text, styling underlines, selection, placeholders or carets, or reviewing frontend code for typography. Triggers on typography, fonts, font formats, woff2, variable fonts, font-weight, opentype, font-feature-settings, letter-spacing, line-height, type scale, heading hierarchy, heading levels, tabular numbers, text-wrap, truncation, line clamp, underlines, text-decoration, text selection, iOS input zoom, scaled input text, font smoothing, text contrast, measure, line length, text-box, smart punctuation, drop cap.

xzedm/clipplic-landing

Design engineering principles for making interfaces feel polished. Use when building UI components, reviewing frontend code, implementing animations, hover states, shadows, borders, micro-interactions, enter/exit animations, choosing or reviewing icons, or any visual detail work. Triggers on UI polish, design details, "make it feel better", "feels off", stagger animations, border radius, optical alignment, image outlines, box shadows, icons, icon stroke weight, icon states, motion restraint.

xzedm/clipplic-landing

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

xzedm/clipplic-landing

Generate developer handoff specs from a design. Use when a design is ready for engineering and needs a spec sheet covering layout, design tokens, component props, interaction states, responsive breakpoints, edge cases, and animation details.

xzedm/clipplic-landing

This skill encodes Emil Kowalski's philosophy on UI polish, component design, animation decisions, and the invisible details that make software feel great.

xzedm/clipplic-landing

Extract design primitives from a public website and generate starter token files for your project.

xzedm/clipplic-landing

Use this skill alongside figma-use when the task involves translating an application page, view, or multi-section layout into Figma. Triggers: 'write to Figma', 'create in Figma from code', 'push page to Figma', 'take this app/page and build it in Figma', 'create a screen', 'build a landing page in Figma', 'update the Figma screen to match code', 'convert this modal/dialog/drawer/panel to Figma'. This is the preferred workflow skill whenever the user wants to build or update a full page, modal, dialog, drawer, sidebar, panel, or any composed multi-section view in Figma from code or a description. Discovers design system components, variables, and styles from Code Connect files, existing screens, and library search, then imports them and assembles views incrementally section-by-section using design system tokens instead of hardcoded values.

xzedm/clipplic-landing

**MANDATORY prerequisite**: you MUST invoke this skill BEFORE every `use_figma` tool call. NEVER call `use_figma` directly without loading this skill first. Skipping it causes common, hard-to-debug failures. Trigger whenever the user wants to perform a write action or a unique read action that requires JavaScript execution in the Figma file context, e.g. create/edit/delete nodes, set up variables or tokens, build components and variants, modify auto-layout or fills, bind variables to properties, or inspect file structure programmatically.

xzedm/clipplic-landing

Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.

xzedm/clipplic-landing

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications.

xzedm/clipplic-landing

Elite UX/UI & Advanced GSAP Motion Engineer. Enforces Python-driven true randomization for layout variance, strict AIDA page structure, wide editorial typography (bans 6-line wraps), gapless bento grids, strict GSAP ScrollTriggers (pinning, stacking, scrubbing), inline micro-images, and massive section spacing.

xzedm/clipplic-landing

Fast headless browser for QA testing and site dogfooding. Navigate pages, interact with elements, verify state, diff before/after, take annotated screenshots, test responsive layouts, forms, uploads, dialogs, and capture bug evidence. Use when asked to open or test a site, verify a deployment, dogfood a user flow, or file a bug with screenshots. (gstack)

関連スキル