ShakibDShy

Custom Navigation

Learn how to customize the navigation controls of your pagination component.

Example

Custom Navigation

Pagination with custom navigation controls

function CustomNavigationExample() {
  const [currentItems, setCurrentItems] = useState(ITEMS.slice(0, 10));
 
  return (
    <div className="space-y-4">
      <h2 className="text-2xl font-bold">Custom Navigation</h2>
      <p className="text-neutral-600">Pagination with custom navigation controls</p>
 
      <Pagination
        totalItems={ITEMS.length}
        defaultPageSize={10}
        previousIcon="⟨"
        nextIcon="⟩"
        navigationButtonVariant="primary"
        navigationButtonColor="secondary"
        onChange={({ currentPage, pageSize }) => {
          const start = (currentPage - 1) * pageSize;
          setCurrentItems(ITEMS.slice(start, start + pageSize));
        }}
      />
    </div>
  );
}

Customization Options

Custom Icons

You can customize the navigation icons using the previousIcon and nextIcon props:

<Pagination
  previousIcon="←"
  nextIcon="→"
/>
 
// Using React Icons
import { FiChevronLeft, FiChevronRight } from 'react-icons/fi';
 
<Pagination
  previousIcon={<FiChevronLeft />}
  nextIcon={<FiChevronRight />}
/>

Customize the appearance of navigation buttons:

<Pagination
  navigationButtonVariant="outline" // or "solid"
  navigationButtonColor="primary" // or "secondary"
  navigationButtonSize="lg" // "sm" | "md" | "lg"
/>

Custom Navigation Labels

Add ARIA labels for better accessibility:

<Pagination
  previousLabel="Previous Page"
  nextLabel="Next Page"
/>

Best Practices

  1. Accessibility: Ensure custom icons are accessible and have proper labels
  2. Consistency: Maintain consistent styling with your application's design
  3. Responsiveness: Test custom navigation on different screen sizes
  4. Visual Feedback: Provide clear visual feedback for hover and active states

Last updated on

On this page