Back to PrequelUIYou are on Page Transition.

Page Transition

Page changes revealed with the View Transitions API.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
page-transition.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/page-transition.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/page-transition.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
page-transition.tsx
"use client";

import * as React from "react";
import { AnimatePresence, motion, type HTMLMotionProps } from "motion/react";
import { cn } from "@/lib/utils";
import { easeInOut, useReduceMotion } from "./motion";

export type PageTransitionProps = Omit<HTMLMotionProps<"div">, "children"> & {
  pageKey: React.Key;
  children: React.ReactNode;
  duration?: number;
  from?: "top" | "bottom" | "left" | "right";
  fade?: boolean;
};

function hiddenClip(from: PageTransitionProps["from"]) {
  switch (from) {
    case "bottom":
      return "inset(100% 0 0 0)";
    case "left":
      return "inset(0 100% 0 0)";
    case "right":
      return "inset(0 0 0 100%)";
    default:
      return "inset(0 0 100% 0)";
  }
}

export function PageTransition({
  pageKey,
  children,
  duration = 0.55,
  from = "top",
  fade = true,
  className,
  ...props
}: PageTransitionProps) {
  const reduce = useReduceMotion();

  return (
    <AnimatePresence mode="wait" initial={false}>
      <motion.div
        key={pageKey}
        data-slot="page-transition"
        initial={
          reduce
            ? { opacity: 0 }
            : { clipPath: hiddenClip(from), opacity: fade ? 0.6 : 1 }
        }
        animate={{ clipPath: "inset(0 0 0% 0)", opacity: 1 }}
        exit={reduce ? { opacity: 0 } : { opacity: 0 }}
        transition={reduce ? { duration: 0 } : { duration, ease: easeInOut }}
        className={cn("min-w-0", className)}
        {...props}
      >
        {children}
      </motion.div>
    </AnimatePresence>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/page-transition.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

page-transition.tsx
import { PageTransition } from "@/components/prequelui/page-transition";

export default function Demo() {
  return (
    <PageTransition pageKey="overview" from="top">
      <h2>A calm overview</h2>
      <p>Every change, in order.</p>
    </PageTransition>
  );
}
import { PageTransition } from "@/components/prequelui/page-transition";

export function Variant() {
  return (
    <PageTransition tempo={1.2}>
      …
    </PageTransition>
  );
}
03

Animation

The new view is revealed by a closing inset from the chosen edge. The outgoing page fades underneath, so the swap reads as one surface turning over rather than two pages stacked.

  • Reveal: 550 ms on cubic-bezier(0.77, 0, 0.175, 1).
  • The inset can start from any of the four edges.
  • The outgoing page fades over the same interval.
  • Reduced motion replaces the inset with a pure fade.
spring 500 / 50pause off-screenpointer-awareinterruptible
04

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

PageTransition

PropTypeDefault
pageKeyKey—
from"top" | "bottom" | "left" | "right""top"
durationnumber0.55
fadebooleantrue
childrenReactNode—

Next component

Pinned List

Items that move between pinned and unpinned groups as the same node.