Skip to content

Pager

Previous/next page navigation bar with arrow indicators.

Preview

Installation

$pnpm exec dgadd add ui/pager
[Installs to]src/components/ui/pager[Item]ui/pager

dgadd is not public on npm yet. Until the first release, pack @diffgazer/add from the repository and install that tarball into this app, which is what puts dgadd on pnpm exec.

UI components require Tailwind CSS v4. Local copy mode imports src/styles/styles.css; package mode uses @diffgazer/ui CSS once packages are available.

Usage

tsx
import { Pager, PagerLink } from "@/components/ui/pager";export default function PagerDefault() {  return (    <div className="mx-auto w-full max-w-2xl">      <Pager>        <PagerLink direction="previous" href="/ui/components/button">          Button        </PagerLink>        <PagerLink direction="next" href="/ui/components/checkbox">          Checkbox        </PagerLink>      </Pager>    </div>  );}

Examples

Single Direction

Preview

Long Titles

Preview

Hover and Focus

Preview

Framework Link (render prop)

Preview

API Reference

Pager

NameTypeDefaultDescription
childrenReactNodePagerLink children. Rendered inside <nav aria-label="Page navigation">.
NameTypeDefaultDescription
directionrequired"previous" | "next"Selects the arrow glyph, rel attribute (prev/next), and alignment.
hrefstringAnchor href. Omit when rendering a framework Link via the render-prop form.
childrenrequiredReactNode | (props: PagerLinkRenderProps) => ReactNodeLink label, or a render function that receives ref, className, rel, direction, and remaining anchor props for framework Link integration.

Accessibility

Notes

Page Spacing

Pager renders only the top rule and the link row. Vertical spacing from the content above is a page decision — add it at the call site (for example className="mt-8").

Link Navigation

Use PagerLink with a direction prop for standard anchor links. For framework-specific link components (TanStack Link, Next.js Link), use the render-prop pattern: <PagerLink direction="next">{(props) => <Link {...props} to="...">text</Link>}</PagerLink>.

Source

Install via CLI: pnpm exec dgadd add ui/pager.

Highlighted source loads after this disclosure opens. Browse the source repository.