Pagination

Pagination is the bridge between overwhelming data and manageable chunks. It turns "too much information" into "just the right amount" with elegant navigation controls.

Preview
Code

Installation

First, make sure you have the required dependencies:

npx @rajdevxd/aura-ui add pagination
yarn @rajdevxd/aura-ui add pagination
pnpm dlx @rajdevxd/aura-ui add pagination
bunx --bun @rajdevxd/aura-ui add pagination

Usage

Here's how to implement pagination:

import { Pagination } from "@/components/ui/pagination"

const MyComponent = () => {
  const [currentPage, setCurrentPage] = React.useState(1)
  const itemsPerPage = 10
  const totalItems = 95
  const totalPages = Math.ceil(totalItems / itemsPerPage)

  return (
    <div>
      {/* Your content here */}
      <Pagination
        currentPage={currentPage}
        totalPages={totalPages}
        onPageChange={setCurrentPage}
      />
    </div>
  )
}

Props

PropTypeRequiredDescription
currentPagenumberYesThe currently active page number
totalPagesnumberYesTotal number of pages available
onPageChange(page: number) => voidYesCallback when page changes
classNamestringNoAdditional CSS classes

Features

  • Smart Navigation: Previous/Next buttons with proper disabled states
  • Page Ellipsis: Shows "..." for large page ranges
  • Keyboard Friendly: Full keyboard navigation support
  • Responsive Design: Adapts to different screen sizes

Common Issues

  1. "Pagination not updating!" - Make sure you're updating currentPage state correctly
  2. "Wrong page count!" - Double-check your totalPages calculation
  3. "Buttons not working!" - Ensure onPageChange callback updates your state

Contributing

Pagination is crucial for data-heavy applications! Help us optimize its performance and UX.

Pagination - because not all data fits on one page! 📄