Pagination
<gcds-pagination>
Also called: page index, page navigation.
Pagination is a division of content into multiple linked pages.
-
GitHub -
Figma
Pagination component preview
On this page
Coding and accessibility for pagination
Set up simple pagination
Use simple pagination for a smaller number of pages.
- Set the
displayattribute tosimple. - Set the previous page’s URL with the
previous-hrefattribute. - Set the previous page’s label with the
previous-labelattribute. - Set the next page’s URL with the
next-hrefattribute. - Set the next page’s label with the
next-labelattribute.
Set up list styled pagination
Use list styled pagination when you are dealing with a larger number of pages.
- Set the
displayattribute tolist. - Set the total number of pages in your sequence with the
total-pagesattribute using a numeric value. - Set the current or active page with the
current-pageattribute using a numeric value. - Opt to use the
urlattribute to provide the component with a group of page links. This can be an object if you are working in a JS environment, or a string if you are using HTML.
Apply the URL object for list-style pagination
Use the url object to generate the query strings and fragments for the list pagination’s links.
url = {
queryStrings: {
// Key value pairs
key: value,
},
fragment: string, // Target id
};
To modify the value based on the page link being rendered, add the object modifiers ::offset or ::match to a key in the queryStrings object.
::offset counts up with the given value starting from the second page link.
url = {
queryStrings: {
'index::offset': 100,
},
};
Using ::match on the current page link being rendered, multiplies it by the value provided.
url = {
queryStrings: {
'page::match': 1,
},
};
Using either ::offset or ::match, allows a number to be injected into a string. Using {{#}}, the modifier will inject the modified number based on the counting method into the string when rendering.
url = {
queryStrings: {
'index::offset': 'index_{{100}}',
'page::match': 'page_{{1}}',
},
};
In this section
label
The label attribute defines the text that labels the pagination navigation landmark, giving it a clear and accessible name.
<gcds-pagination label="List pagination example" total-pages="15" current-page="9">
</gcds-pagination>
current-page
The current-page attribute sets the current page for a pagination with list display.
<gcds-pagination label="List pagination example" total-pages="15" current-page="9">
</gcds-pagination>
display
The display attribute sets the display style of the pagination. The available options are:
list(default)simple
<gcds-pagination label="List pagination example" display="list" total-pages="15" current-page="9">
</gcds-pagination>
next-href
The next-href attribute specifies the next page’s URL for a pagination with simple display.
<gcds-pagination label="Simple pagination example" display="simple" previous-href="#" next-href="#" previous-label="Title of page" next-label="3 of 3">
</gcds-pagination>
next-label
The next-label attribute defines the next page’s label for a pagination with simple display.
<gcds-pagination label="Simple pagination example" display="simple" previous-href="#" next-href="#" previous-label="Title of page" next-label="3 of 3">
</gcds-pagination>
previous-href
The previous-href attribute specifies the previous page’s URL for a pagination with simple display.
<gcds-pagination label="Simple pagination example" display="simple" previous-href="#" next-href="#" previous-label="Title of page" next-label="3 of 3">
</gcds-pagination>
previous-label
The previous-label attribute defines the previous page’s label for a pagination with simple display.
<gcds-pagination label="Simple pagination example" display="simple" previous-href="#" next-href="#" previous-label="Title of page" next-label="3 of 3">
</gcds-pagination>
total-pages
The total-pages attribute sets the total number of pages for a pagination with list display.
<gcds-pagination label="List pagination example" total-pages="15" current-page="9">
</gcds-pagination>
url
The url attribute defines the object (in a JavaScript environment) or string (in HTML) that generates the query strings and fragment for the list-styled pagination links.
<gcds-pagination label="List pagination example" total-pages="15" current-page="9" url='{"queryStrings": { "querystring::offset": 10 }, "fragment": "main" }'>
</gcds-pagination>
Code builder
Generate an instance of the component you need by selecting its code properties.
-
Explore by choosing different code values to generate the instance you want.
-
Get the code and pull it into your environment.
-
Add any copy you need to the component (like text for a label).
Note: The code builder uses English for all code elements, which follows standard practice.
Help us improve
Have questions or a request? Give feedback on our contact form.
Something's wrong? Raise it through GitHub with an