# Pagination

Page navigation, page size and direct page entry.

Access: pro. Category: Navigation. Kind: composite.

## When to use

- Use it when a page needs page navigation, page size and direct page entry.
- Choose it as the nav region when composing a page from independently reusable TidalUI sections.

## Alternatives

- Choose navigation-bar instead when responsive saas navigation with native links, actions and an in-flow mobile disclosure is the actual interface need, rather than pagination.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Pagination

```sh
npx shadcn@latest add @tidal-pro/pagination
```

Stylesheets: `components/ui/tidal.css`, `components/ui/pagination.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/pagination.css";
import{TidalPagination}from"./components/ui/pagination";
export default()=><div className="tidal-scope"><TidalPagination onPageChange={() => {}} page={1} pageCount={1}/></div>;
```

## Structured props

- `TidalPagination.onPageChange: (page: number) => void`: Callback invoked when the page change interaction is proposed.
- `TidalPagination.page: number`: Required page value accepted by this exported component.
- `TidalPagination.pageCount: number`: Required page count value accepted by this exported component.
- `TidalPagination.disabled?: boolean | undefined` (default false): Optional disabled value accepted by this exported component.
- `TidalPagination.getHref?: ((page: number) => string) | undefined`: Optional get href value accepted by this exported component.
- `TidalPagination.label?: string | undefined` (default "Pagination"): Optional label value accepted by this exported component.
- `TidalPagination.theme?: "light" | "dark" | undefined` (default "light"): Optional theme value accepted by this exported component.
- `TidalPagination.windowSize?: number | undefined` (default 7): Optional window size value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/pagination.tsx) | [Manifest](https://tidalui.com/examples/pagination.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useLayoutEffect, useRef, useState, type CSSProperties } from "react";

import { FileText } from "lucide-react";

import { TidalPagination } from "./components/ui/pagination";

import "./components/ui/pagination.css";



const tidalExampleStyles = ".pagination-specimen {\n  width: 100%;\n  max-width: 700px;\n  padding: 28px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-card);\n  background: var(--t-surface);\n  box-shadow:\n    0 24px 40px -28px #00000035,\n    0 2px 4px #00000008;\n}\n.pagination-specimen > h3 {\n  font-size: 29px;\n  line-height: 1.08;\n  letter-spacing: -1px;\n  font-weight: 500;\n  margin: 13px 0 26px;\n}\n.pagination-specimen > h3 > em {\n  font-family: \"Instrument Serif\", serif;\n  font-size: 1.2em;\n  font-weight: 400;\n}\n.pagination-demo-archive {\n  border: 1px solid var(--t-border);\n  border-radius: 13px;\n  background: var(--t-subtle);\n  overflow: hidden;\n}\n.pagination-demo-range {\n  display: flex;\n  align-items: center;\n  justify-content: flex-start;\n  padding: 14px 22px;\n  border-bottom: 1px solid var(--t-border);\n  color: var(--t-ink);\n  font-size: 13px;\n  line-height: 1.2;\n}\n.pagination-demo-stage {\n  padding: 6px 0;\n  margin: 0;\n  overflow: hidden;\n  transition: height 420ms var(--t-ease-out);\n}\n.pagination-demo-content {\n  display: flow-root;\n}\n.pagination-demo-list {\n  margin: 0;\n  padding: 8px 16px;\n  list-style: none;\n  display: grid;\n  gap: 7px;\n}\n.pagination-demo-list > li {\n  display: flex;\n  align-items: center;\n  gap: 13px;\n  padding: 12px 14px;\n  min-height: 76px;\n  background: var(--t-surface);\n  border: 1px solid var(--t-border);\n  border-radius: 10px;\n  animation: pagination-record-in 420ms var(--t-ease-out) var(--record-delay)\n    both;\n}\n.pagination-demo-list > li > div:nth-child(2) {\n  min-width: 0;\n  flex: 1;\n}\n.pagination-demo-paper {\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  gap: 6px;\n  width: 35px;\n  height: 44px;\n  border: 1px solid var(--t-border);\n  border-radius: 5px;\n  background: var(--t-subtle);\n  box-shadow: 0 2px 4px #00000008;\n  transform: rotate(-4deg);\n  animation: pagination-paper-in 620ms var(--t-ease-spring) var(--record-delay)\n    both;\n}\n.pagination-demo-paper > span {\n  display: grid;\n  gap: 2px;\n  width: 100%;\n  justify-items: center;\n}\n.pagination-demo-paper i {\n  display: block;\n  height: 1px;\n  background: var(--t-muted);\n  opacity: 0.45;\n}\n.pagination-demo-record-id {\n  display: block;\n  font-size: 11px;\n  letter-spacing: 0.7px;\n  color: var(--t-muted);\n}\n.pagination-demo-list h5 {\n  font-size: 13px;\n  line-height: 1.35;\n  font-weight: 500;\n  margin: 4px 0 3px;\n  letter-spacing: -0.2px;\n}\n.pagination-demo-list p {\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.4;\n  margin: 0;\n}\n.pagination-demo-record-status {\n  font-size: 11px;\n  white-space: nowrap;\n  border: 1px solid var(--t-border);\n  border-radius: 5px;\n  padding: 4px 7px;\n  background: var(--t-wash);\n  color: var(--t-muted);\n}\n.pagination-demo-record-status[data-ready=\"true\"] {\n  background: var(--t-ink);\n  border-color: var(--t-ink);\n  color: var(--t-surface);\n}\n.pagination-demo-footer {\n  padding: 15px 20px 9px;\n  background: var(--t-surface);\n}\n.pagination-demo-note {\n  display: flex;\n  align-items: flex-start;\n  gap: 7px;\n  font-size: 11px;\n  color: var(--t-muted);\n  line-height: 1.7;\n  margin: 16px 0 0;\n}\n.pagination-demo-note svg {\n  margin-top: 2px;\n}\n@keyframes pagination-record-in {\n  from {\n    opacity: 0;\n    transform: translateX(9px);\n  }\n  to {\n    opacity: 1;\n    transform: none;\n  }\n}\n.pagination-specimen[data-direction=\"back\"] .pagination-demo-list > li {\n  animation-name: pagination-record-back;\n}\n@keyframes pagination-record-back {\n  from {\n    opacity: 0;\n    transform: translateX(-9px);\n  }\n  to {\n    opacity: 1;\n    transform: none;\n  }\n}\n@keyframes pagination-paper-in {\n  from {\n    opacity: 0;\n    transform: rotate(-11deg) scale(0.92);\n  }\n  to {\n    opacity: 1;\n    transform: rotate(-4deg);\n  }\n}\n@media (max-width: 480px) {\n  .pagination-specimen {\n    padding: 20px;\n  }\n  .pagination-demo-range {\n    padding: 12px 15px;\n  }\n  .pagination-demo-list {\n    padding: 8px 10px;\n  }\n  .pagination-demo-list > li {\n    gap: 10px;\n    padding: 11px 10px;\n  }\n  .pagination-demo-record-status {\n    display: none;\n  }\n  .pagination-demo-list h5 {\n    font-size: 12px;\n  }\n  .pagination-demo-footer {\n    padding: 13px 10px 7px;\n  }\n}\n@media (prefers-reduced-motion: reduce) {\n  .pagination-demo-paper {\n    transform: none;\n  }\n}";

const titles = [
  "First impressions",
  "A little hierarchy",
  "Clearer navigation",
  "The welcome screen",
  "A space to choose",
  "Thoughtful defaults",
  "The empty state",
  "Signals and status",
  "The project overview",
  "Writing for the interface",
  "Connected settings",
  "The right amount of motion",
  "A quieter dashboard",
  "Keeping your place",
  "The invitation flow",
  "A considered form",
  "Before and after",
  "The shortcut map",
  "The workspace switcher",
  "A moment of feedback",
  "Reading on small screens",
  "The search experience",
  "A clearer comparison",
  "The first five minutes",
  "A little less friction",
  "An honest progress bar",
  "When things go wrong",
  "The handoff notes",
  "A meaningful metric",
  "The detail view",
  "Naming the next step",
  "A calm notification",
  "The billing overview",
  "Preparing a release",
  "Making space",
  "One shared language",
  "The final small details",
];

const records = titles.map((title, index) => ({
  id: index + 1,
  title,
  category: ["Interface", "Experience", "Writing", "Motion"][index % 4],
  status: ["Draft", "In review", "Ready"][index % 3],
  lines: 8 + (index % 9),
}));

export function PaginationDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const [page, setPage] = useState(1);
  const [direction, setDirection] = useState("forward");
  const [height, setHeight] = useState<number>();
  const content = useRef<HTMLDivElement>(null);
  const items = records.slice((page - 1) * 4, page * 4);
  const start = (page - 1) * 4 + 1;
  const end = Math.min(page * 4, records.length);
  useLayoutEffect(() => {
    const node = content.current;
    if (!node) return;
    const measure = () => {
      const stageStyle = getComputedStyle(node.parentElement!);
      setHeight(
        node.offsetHeight +
          Number.parseFloat(stageStyle.paddingTop) +
          Number.parseFloat(stageStyle.paddingBottom),
      );
    };
    measure();
    const observer = new ResizeObserver(measure);
    observer.observe(node);
    return () => observer.disconnect();
  }, []);
  return (
    <div className="pagination-specimen" data-direction={direction}>
      <div className="pagination-demo-archive">
        <div className="pagination-demo-range" data-single={start === end}>
          <span role="status">
            Showing {start === end ? start : `${start}–${end}`} of 37 sample
            records
          </span>
        </div>
        <div className="pagination-demo-footer">
          <TidalPagination
            page={page}
            pageCount={Math.ceil(records.length / 4)}
            onPageChange={(next) => {
              setDirection(next > page ? "forward" : "back");
              setPage(next);
            }}
            label="Sample archive pages"
            theme={theme}
          />
        </div>
        <div className="pagination-demo-stage" style={{ height }}>
          <div ref={content} className="pagination-demo-content">
            <ul key={page} className="pagination-demo-list">
              {items.map((record, index) => (
                <li
                  key={record.id}
                  style={
                    {
                      "--record-delay": `${45 + index * 55}ms`,
                    } as CSSProperties
                  }
                >
                  <div className="pagination-demo-paper" aria-hidden="true">
                    <FileText size={18} />
                    <span>
                      {Array.from({ length: 3 }, (_, n) => (
                        <i
                          key={n}
                          style={{
                            width: `${28 + ((record.id + n * 2) % 9) * 3}%`,
                          }}
                        />
                      ))}
                    </span>
                  </div>
                  <div>
                    <span className="pagination-demo-record-id">
                      NOTE {String(record.id).padStart(2, "0")} ·{" "}
                      {record.category.toUpperCase()}
                    </span>
                    <h5>{record.title}</h5>
                    <p>{record.lines} lines · Original fictional content</p>
                  </div>
                  <span
                    className="pagination-demo-record-status"
                    data-ready={record.status === "Ready"}
                  >
                    {record.status}
                  </span>
                </li>
              ))}
            </ul>
          </div>
        </div>
      </div>
      <p className="pagination-demo-note">
        Page through 37 fictional records. This preview stays in the browser.
      </p>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <PaginationDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation.","Escape dismisses the open overlay where the underlying primitive supports dismissal."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"The implementation includes reduced-motion behavior; verify it with the consumer's final content."}

Required controlled page (1-based), pageCount and onPageChange. Finite counts floor/clamp0..MAX_SAFE_INTEGER; nonfinite or nonpositive counts show No pages, and page clamps into the available range without mutating caller state. Optional label(defaultPagination), windowSize(default7; floors/clamps1..9), disabled, getHref(page):string, theme(light|dark; pass for modal), native nav attributes/ref/className/style. ResizeObserver adapts visible page slots to the container while retaining the current page; larger windows retain boundary pages and actionable gaps, smaller windows stay contiguous. Tab/Enter/Space native buttons; anchors with getHref preserve modified-click navigation while primary clicks invoke onPageChange. Disabled anchors become noninteractive spans without href. Current control carries aria-current=page. Page summary and gaps open a labelled Radix modal for strict whole-number page input, trapped focus, Escape/close and focus return. Stable keyed numbers and a measured current marker move continuously; reduced motion resolves immediately. SSR has a static selected-control fallback. The caller owns routing, records, loading, announcements and content focus.
