For the complete documentation index, see llms.txt. Markdown variants are available by appending .md to any URL or sending an Accept: text/markdown header. An agent skill is available at /.well-known/agent-skills/site-skill.md.
Shadcn Labs/

Page Transition

PageTransition and navigateWithTransition: route changes animated by React's <ViewTransition>. Animate navigation with ready-made styles, installed with the shadcn CLI.

acme.studio/
Studio

We build interfaces that feel fast.

Design and engineering for teams who care about every frame.

FastEvery route ships under 50 kB.
ComposableBlocks that snap together.
TypedEnd-to-end type safety.

Installation

$ pnpm dlx shadcn@latest add @transition-kit/page-transition

Setup

components/page-transitions.tsx
"use client";
 
import { usePathname } from "next/navigation";
import type { ReactNode } from "react";
 
import { PageTransition } from "@/components/transitions/page-transition";
 
export const PageTransitions = ({ children }: { children: ReactNode }) => {
  const pathname = usePathname();
 
  return (
    <PageTransition id={pathname} transition="slide" className="bg-background">
      {children}
    </PageTransition>
  );
};
app/layout.tsx
import { PageTransitions } from "@/components/page-transitions";
import { SiteHeader } from "@/components/site-header";
 
export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        <SiteHeader />
        <PageTransitions>{children}</PageTransitions>
      </body>
    </html>
  );
}
<Link href="/" transitionTypes={["page-back"]}>
  Back
</Link>
router.push("/", { transitionTypes: ["page-back"] });

API Reference

PageTransition

PropTypeDefaultDescription
idstring-Identifies the current page, usually the pathname. The old page exits and the new one enters when it changes inside a Transition.
transitionstring"fade"Style slug. Fade ships with the core.
durationnumber-Milliseconds. Overrides the style's timing.
easingstring-Overrides the style's easing.
childrenReactNode-The routed content.
...propsComponentProps<"div">-Spread onto the <div data-slot="page-transition"> that wraps each page and is snapshotted.
navigateWithTransition(navigate: () => void, options?: { direction?: "forward" | "back" }): void
ParamTypeDefaultDescription
navigate() => void-Anything updating the state id comes from: router.push, React Router's navigate, or setState. Runs inside startTransition.
options.direction"forward" | "back""forward""back" plays directional styles in reverse.

PAGE_BACK_TYPE

FieldTypeDescription
PAGE_BACK_TYPE"page-back"Pass it to your router's own transition types API instead of navigateWithTransition.

Styles