Components

Pagination

Animated React pagination for shadcn/ui and Tailwind CSS: the drop-in Pagination adds a clear current page, asChild links and focus-safe disabled states — plus a Motion block whose active indicator glides between pages, whose numbers roll as the range shifts, and whose smart ellipsis keeps the bar a constant width.

  • Drop-in shadcn API
  • Motion layoutId
  • Smart ellipsis range
  • aria-current
  • prefers-reduced-motion

Showing 1–10 of 240 results

Installation

$ npx shadcn@latest add https://duskui.com/r/pagination.json

Replaces components/ui/pagination.tsx with the same parts and data-slot attributes. It styles links with buttonVariants from the DuskUI Button, which the registry installs for you.

Usage

results-pagination.tsx
import {
  Pagination,
  PaginationContent,
  PaginationEllipsis,
  PaginationItem,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"

export function ResultsPagination() {
  return (
    <Pagination>
      <PaginationContent>
        <PaginationItem>
          <PaginationPrevious href="?page=1" />
        </PaginationItem>
        <PaginationItem>
          <PaginationLink href="?page=1">1</PaginationLink>
        </PaginationItem>
        <PaginationItem>
          <PaginationLink href="?page=2" isActive>2</PaginationLink>
        </PaginationItem>
        <PaginationItem>
          <PaginationEllipsis />
        </PaginationItem>
        <PaginationItem>
          <PaginationNext href="?page=3" />
        </PaginationItem>
      </PaginationContent>
    </Pagination>
  )
}

Examples

Default

The shadcn composition with an outlined current page. Here asChild renders buttons for local state, and aria-disabled dims Previous / Next at the ends without stealing keyboard focus.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Animated Pagination

Pass totalPages and a controlled page (or defaultPage). The indicator glides to the current page via a shared Motion layoutId, and numbers roll up or down as the window of pages shifts. The range always has the same number of slots, so the bar never changes width. Focus follows the page you pick.

Showing 1–10 of 240 results

$ npx shadcn@latest add https://duskui.com/r/animated-pagination.json
PropTypeDefaultDescription
totalPagesnumber—Number of pages.
page / onPageChangenumber / (page: number) => void—Controlled current page (1-based).
defaultPagenumber1Uncontrolled initial page.
siblingCountnumber1Pages shown on each side of the current one.
boundaryCountnumber1Pages always shown at the start and end.
showControlsbooleantrueShow the Previous / Next buttons.
labels{ previous, next } | null"Previous" / "Next"Button text (hidden below sm). null for icon-only.
getPageHref(page: number) => string—Render real links instead of buttons (good for SEO).
linkAsElementType"a"Link component used with getPageHref, e.g. Next.js Link.

Animated Pagination — compact & wide

labels={null} gives icon-only arrows. siblingCount={0} makes a tight bar for mobile; raise siblingCount and boundaryCount for wide layouts. The helper getPaginationItems is exported if you want the range for your own markup.

$ npx shadcn@latest add https://duskui.com/r/animated-pagination.json

Animated Pagination — few pages

With few pages every number is shown and the indicator simply glides between them. Rename the controls with labels — e.g. Newer / Older for a blog.

$ npx shadcn@latest add https://duskui.com/r/animated-pagination.json

API Reference

Same parts as shadcn/ui: Pagination (a nav), PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext and PaginationEllipsis. The additions are below.

PropTypeDefaultDescription
isActivebooleanfalseOn PaginationLink: sets aria-current="page" and the active style.
asChildbooleanfalseOn PaginationLink / Previous / Next: render your Link or a <button>. An empty child gets the default chevron and label.
sizeButton size"icon"On PaginationLink: any DuskUI Button size.
aria-disabledboolean—Dims the link and blocks pointer clicks while keeping it focusable.

Accessibility

  • Pagination renders a nav landmark labelled “pagination”; rename it with aria-label when a page has several.
  • The current page carries aria-current="page"; the gliding indicator is decorative and aria-hidden.
  • Previous / Next use aria-disabled at the ends, so keyboard focus isn't dropped when you reach the first or last page.
  • Animated Pagination gives every number an accessible name (“Go to page 7”) and moves focus to the newly selected page, since the slot you clicked may now show another number.
  • The ellipsis is announced as “More pages” rather than being silently skipped.
  • Under prefers-reduced-motion the indicator jumps and numbers crossfade without sliding.