1 min read

View transitions for portfolios

You don't need a single-page app to get smooth page changes anymore. Two lines of CSS make a multi-page portfolio feel like one continuous canvas.

React source code on a dark monitor

Single-page apps became popular in portfolios mostly because of transitions: the project image grows into the case study, the header stays where it is. With cross-document view transitions, the browser does this for normal links between normal pages.

Opt in on both pages

css
@view-transition {
    navigation: auto;
}

.project-cover {
    view-transition-name: cover;
}

Both the old and the new page need the @view-transition rule. Elements with the same view-transition-name on both pages morph into each other, everything else cross-fades.

Important

Each view-transition-name must be unique on a page. Set it only on the cover of the project the user clicked, not on every card in the grid.

Keep it fast

The browser waits for the new page before it animates. A slow page makes every transition feel sluggish, so the transition is also a nice reminder to keep your pages light.