Skip to content

feat: add View Transitions API support for client-side navigation#3708

Merged
bartlomieju merged 6 commits into
mainfrom
feat/view-transitions
Mar 29, 2026
Merged

feat: add View Transitions API support for client-side navigation#3708
bartlomieju merged 6 commits into
mainfrom
feat/view-transitions

Conversation

@bartlomieju

@bartlomieju bartlomieju commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Integrates the View Transitions API into Fresh's existing partials system
  • Opt-in via f-view-transition attribute, progressive enhancement (falls back gracefully)
  • Wraps all navigation types (link clicks, popstate, form submissions) in document.startViewTransition()

Usage

<body f-client-nav f-view-transition>
  <!-- your app -->
</body>

Customize animations with standard CSS:

::view-transition-old(root) {
  animation: fade-out 0.2s ease-in;
}
::view-transition-new(root) {
  animation: fade-in 0.2s ease-out;
}

Per-element transitions work via view-transition-name:

.sidebar { view-transition-name: sidebar; }

Design decisions

  • Opt-in — only activates when f-view-transition attribute is present, can be disabled with f-view-transition="false"
  • Progressive — falls back to regular partial updates when the browser doesn't support the View Transitions API
  • Minimal — 35 lines of implementation, integrates into existing partials infrastructure rather than building a parallel navigation system

Supersedes #1532
Closes #3458

Test plan

  • View transitions called when f-view-transition is present
  • View transitions NOT called without f-view-transition
  • View transitions NOT called when f-view-transition="false"
  • View transitions work with popstate (back/forward) navigation

🤖 Generated with Claude Code

bartlomieju and others added 2 commits March 26, 2026 18:00
Integrates the View Transitions API into Fresh's existing partials
system. When enabled via the `f-view-transition` attribute, partial
updates are wrapped in `document.startViewTransition()` for smooth
animated transitions between pages.

Usage:
  <body f-client-nav f-view-transition>

The API is opt-in and progressive:
- Only activates when `f-view-transition` attribute is present
- Falls back to regular updates when the View Transitions API
  is not supported by the browser
- Works with all navigation types: link clicks, popstate, and
  form submissions

Users can customize animations via standard CSS:
  ::view-transition-old(root) { animation: ... }
  ::view-transition-new(root) { animation: ... }

Supersedes #1532

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests cover:
- View transitions called when f-view-transition is present
- View transitions NOT called without f-view-transition
- View transitions NOT called when f-view-transition="false"
- View transitions work with popstate (back/forward) navigation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bartlomieju and others added 4 commits March 26, 2026 19:52
Documents the f-view-transition attribute, how to enable it,
customize animations with CSS, and disable it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Extract the View Transitions section from partials.md into its own
page with expanded content: per-element transitions, direction-aware
animations, browser support. Replace inline section with cross-link.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Keep main's new tests and append view transition tests after them.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju enabled auto-merge (squash) March 29, 2026 19:54
@bartlomieju bartlomieju merged commit 400e217 into main Mar 29, 2026
9 checks passed
@bartlomieju bartlomieju deleted the feat/view-transitions branch March 29, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fresh 2.0 View Transitions JS API support

1 participant