NK

Search

Search pages, posts, and components

All components

Dot Pagination

Navigation

Dot pagination where the active dot stretches into a pill.

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/dot-pagination.json
Or install manually
  1. 1. Install dependencies

    pnpm add motion clsx tailwind-merge
  2. 2. Copy the component source into components/library/dot-pagination.tsx

Props

PropTypeDefaultDescription
countnumber4Number of pages.
activenumber0Initially active index.
onChange(index: number) => void - Called with the new index.

Accessibility

  • aria-current marks the active page; each dot has an aria-label.
  • The active dot changes width as well as colour.
  • Real buttons, so the control is keyboard reachable.

Dependencies

motionclsxtailwind-merge