Pagination
Pagination
is a component which has first, previous, next, and last page buttons. It includes text that informs a user the total number of pages and which page they are currently visiting. The Pagination
component is fully accessible and keyboard navigable.
Accessibility features
aria-label
informs the user whether they will navigate to the previous page, next page, and which page number.aria-hidden
to hide the icons for previous and next pages- Disables the first and previous page buttons when on the first page
- Disables the last and next page buttons when on the last page
Usage
Accessible Astro exports one pagination-related components:
Pagination
: The pagination component
Props
Pagination
Props
firstPage
- Description: A path to the first page
- Type:
string
- Default:
"#"
prevousPage
- Description: A path to the previous page
- Type:
string
- Default:
"#"
nextPage
- Description: A path to the next page
- Type:
string
- Default:
"#"
lastPage
- Description: A path to the last page
- Type:
string
- Default:
"#"
currentPage
- Description: The current page number
- Type:
number
- Default:
1
totalPages
- Description: The total number of pages
- Type:
number
- Default:
12
renderProgress
- Description: A function that returns a string to display current page and total pages
- Type:
- Default:
Example
Style customizations
Customize styles by:
- setting individual properties with a
:global(body .{class)
selector (see Anatomy for class name reference) - setting a global style tag to define styles
Anatomy
Class | Description |
---|---|
pagination | The root container for the pagination component |
pagination__list | Styles applied to the unordered list |