shadcn.io is not affiliated with official shadcn/ui
Pagination examples · Advanced
Disabled State Pagination for React
Pagination on the first page, with Previous disabled because there is no page before it.
Page 1 is current, so there is nowhere to go back to: Previous is disabled, faded and out of the tab order, while Next and the page numbers work. Disable the same way on the last page for Next.
Preview
Installation
FAQ
How is Previous disabled?
PaginationPrevious takes aria-disabled="true", which the button styles fade and make ignore the pointer, and tabIndex -1, which takes it out of the tab order.
How do screen readers hear the disabled link?
As Go to previous page, dimmed or unavailable, because of aria-disabled. It stays in the reading order, so people know the control exists.
How is page 1 marked current?
isActive on that PaginationLink gives it the outline style and aria-current="page". Pages 2 and 3 are ghost links.
How do I disable Next on the last page?
The same way, on PaginationNext, when the current page is the last one. Decide both from your current page and page count.
Related
- Start Ellipsis PaginationPagination near the end, with an ellipsis
- Many Pages PaginationTen page numbers in a row with page 5 as
- Basic Data Table with CheckboxesA table of products with a checkbox on
- Both Ellipsis PaginationPagination on page 6 of 20, with an
- End Ellipsis PaginationPagination near the start, with an
- Complete PaginationPagination with Previous and Next, the