ShakibDShy

Disabled States

Learn how to manage and customize disabled states in your pagination component.

Example

Disabled States

Pagination with various disabled states

function DisabledStatesExample() {
  const [currentItems, setCurrentItems] = useState(ITEMS.slice(0, 10));
 
  return (
    <div className="space-y-4">
      <h2 className="text-2xl font-bold">Disabled States</h2>
      <p className="text-neutral-600">Pagination with various disabled states</p>
 
      <div className="flex flex-col gap-4">
        {/* Fully disabled */}
        <Pagination
          totalItems={ITEMS.length}
          defaultPageSize={10}
          isDisabled={true}
          onChange={({ currentPage, pageSize }) => {
            const start = (currentPage - 1) * pageSize;
            setCurrentItems(ITEMS.slice(start, start + pageSize));
          }}
        />
 
        {/* Disabled navigation */}
        <Pagination
          totalItems={ITEMS.length}
          defaultPageSize={10}
          isDisabledPrevious={true}
          isDisabledNext={true}
          onChange={({ currentPage, pageSize }) => {
            const start = (currentPage - 1) * pageSize;
            setCurrentItems(ITEMS.slice(start, start + pageSize));
          }}
        />
      </div>
    </div>
  );
}

Disabled State Options

Full Component Disable

Disable the entire pagination component:

<Pagination
  isDisabled={true}
  // ... other props
/>

Selective Navigation Disable

Disable specific navigation buttons:

<Pagination
  isDisabledPrevious={true} // Disable previous button
  isDisabledNext={true} // Disable next button
  // ... other props
/>

Conditional Disabling

Disable based on conditions:

<Pagination
  isDisabledPrevious={currentPage === 1}
  isDisabledNext={currentPage === totalPages}
  // ... other props
/>

Styling Disabled States

The component automatically applies appropriate styles to disabled elements:

  • Reduced opacity
  • Removed hover effects
  • Changed cursor style
  • ARIA attributes for accessibility

Best Practices

  1. Clear Feedback: Ensure disabled states are visually distinct
  2. Accessibility: Maintain proper ARIA attributes for screen readers
  3. User Experience: Provide tooltips or messages explaining why controls are disabled
  4. Consistency: Keep disabled state styling consistent across your application

Last updated on

On this page