April 8, 2026/Simple/Page Transitions

View Transitions API

Old page scales down and slides up off screen. New page slides in from below. Uses the browser's native View Transitions API with document.startViewTransition(). No overlay components needed.

Home

Uses the native View Transitions API

"use client";

import { useState, useCallback } from "react";
import styles from "./styles.module.css";

const PAGES = [
  { key: "home", label: "Home", bg: "#f5f5f5", color: "#1a1a1a" },
  { key: "about", label: "About", bg: "#0d0d0d", color: "#ffffff" },
  { key: "work", label: "Work", bg: "#1a1f2e", color: "#ffffff" },
];

export default function ViewTransitionsApi() {
  const [pageIndex, setPageIndex] = useState(0);

  const navigate = useCallback((nextIndex) => {
    if (nextIndex === pageIndex) return;

    if (!document.startViewTransition) {
      setPageIndex(nextIndex);
      return;
    }

    document.startViewTransition(() => {
      setPageIndex(nextIndex);
    });
  }, [pageIndex]);

  const page = PAGES[pageIndex];

  return (
    <div className={styles.demo}>
      <div
        className={styles.page}
        style={{ background: page.bg, color: page.color }}
      >
        <h2 className={styles.pageTitle}>{page.label}</h2>
        <p className={styles.hint}>Uses the native View Transitions API</p>
      </div>

      <div className={styles.nav}>
        {PAGES.map((p, i) => (
          <button
            key={p.key}
            className={`${styles.navBtn} ${i === pageIndex ? styles.active : ""}`}
            onClick={() => navigate(i)}
          >
            {p.label}
          </button>
        ))}
      </div>
    </div>
  );
}

Related Components

1W AGO
Signifly Theme Fadepage-transitions
3MO AGO
Section Transition Systempage-transitions
3MO AGO
Shutter Sectionpage-transitions