Back to Base UIYou are on Pagination.

Pagination

Page links with an active outline that glides between positions.

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

Libraries

Base UI

Motion

Spring + short tween

Reduced motion

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

Installation

Installing for React·components/prequelui/pagination.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/pagination.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
pagination.tsx
"use client";

import * as React from "react";
import { motion, useReducedMotion } from "motion/react";
import { ChevronLeft, ChevronRight } from "lucide-react";
import { cn } from "@/lib/utils";

export type PaginationProps = {
  pages?: number;
  defaultPage?: number;
  page?: number;
  onPageChange?: (page: number) => void;
  className?: string;
};

const glide = { type: "spring", stiffness: 500, damping: 40 } as const;

export function Pagination({
  pages = 5,
  defaultPage = 1,
  page,
  onPageChange,
  className,
}: PaginationProps) {
  const [internal, setInternal] = React.useState(defaultPage);
  const value = page ?? internal;
  const reduce = useReducedMotion();
  const layout = React.useId();

  const go = (next: number) => {
    const clamped = Math.min(pages, Math.max(1, next));
    if (page === undefined) setInternal(clamped);
    onPageChange?.(clamped);
  };

  return (
    <nav aria-label="Pagination" className={cn("flex items-center gap-1", className)}>
      <button
        type="button"
        aria-label="Previous page"
        disabled={value === 1}
        onClick={() => go(value - 1)}
        className="flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40"
      >
        <ChevronLeft className="size-4" />
      </button>
      {Array.from({ length: pages }, (_, index) => index + 1).map((item) => (
        <button
          key={item}
          type="button"
          aria-current={item === value ? "page" : undefined}
          onClick={() => go(item)}
          className="relative flex size-8 items-center justify-center rounded-md text-[13px] font-medium"
        >
          {item === value && (
            <motion.span
              layoutId={`pagination-active-${layout}`}
              className="absolute inset-0 rounded-md border bg-background shadow-sm"
              transition={reduce ? { duration: 0 } : glide}
            />
          )}
          <span className={cn("relative", item === value ? "text-foreground" : "text-muted-foreground")}>
            {item}
          </span>
        </button>
      ))}
      <button
        type="button"
        aria-label="Next page"
        disabled={value === pages}
        onClick={() => go(value + 1)}
        className="flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent disabled:opacity-40"
      >
        <ChevronRight className="size-4" />
      </button>
    </nav>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/react/pagination.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.

pagination.tsx
import { Pagination } from "@/components/prequelui/pagination";

export default function Demo() {
  return (
    <Pagination>
      {/* compose the parts exactly like the underlying primitive */}
    </Pagination>
  );
}
import { Pagination } from "@/components/prequelui/pagination";

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

Animation

This primitive keeps the API and semantics of the underlying component and adds motion at the surface edges. Entrances are slower and more settled than exits, so closing never feels like waiting.

  • Springs for position, scale and size; tweens for colour and opacity.
  • The exit is shorter than the entrance, and keeps the current position as its starting point.
  • All measurements are taken again when content or font metrics change.
  • With reduced motion, the surface fades in place and never travels.
spring 300 / 30exit 150 msblur 4 pxheight 450 ms
04

API Reference

Every part takes exactly the props of the Pagination primitive. The animated surface adds only motion props, so the accessibility tree and keyboard behaviour stay the same.

Pagination

PropTypeDefault
childrenReactNode—
disabledbooleanfalse
transitionTransitionspring.press
classNamestring—

Next component

Popover

An anchored surface that grows from 80% with a spring.