Skip to content

Pagination - How to disable buttons? #2149

Discussion options

You must be logged in to vote

I ran into the same issue with needing to disable the "Previous" and "Next" Links in dynamic client-side pagination, here is a potential solution using the PaginationPrevious component that worked for me:

  <PaginationItem>
          <PaginationPrevious
            href={createPageURL(currentPage - 1)}
            aria-disabled={currentPage <= 1}
            tabIndex={currentPage <= 1 ? -1 : undefined}
            className={
              currentPage <= 1 ? "pointer-events-none opacity-50" : undefined
            }
          />

This code disables the button visually and functionally when on the first page by:

Setting aria-disabled to true.
Setting tabIndex to -1.
Applying CSS classes: p…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@skittlexyz
Comment options

@fathuurr
Comment options

Answer selected by osorionicolas
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants