Pagination - How to disable buttons? #2149
-
Due to nature of the Link component and the a tag, the pagination items don't have an option to disable them, would it be better to replace them by buttons or there is any way to achieve that? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
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:
This code disables the button visually and functionally when on the first page by: Setting aria-disabled to true. I hope it helps :) |
Beta Was this translation helpful? Give feedback.
-
Here is a version of the shadcn-ui pagination components I've created which incorporates the solution @DariusLukasukas provided, plus adds PaginationFirst and PaginationLast components:
You just have to supply the top-level I've only lightly tested my changes, though. Hopefully, they will save someone some time. |
Beta Was this translation helpful? Give feedback.
-
fwiw, I just went with |
Beta Was this translation helpful? Give feedback.
-
Hi, this worked in my use case. I just changed the a tag for button tag in the component and also the props type (React.ComponentProps<"a"> by React.ComponentProps<"button">). `type PaginationLinkProps = { const PaginationLink = ({ |
Beta Was this translation helpful? Give feedback.
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:
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…