Pagination
<gcds-pagination>
Also called: page index, page navigation.
Pagination is a division of content into multiple linked pages.
-
GitHub -
Figma
Pagination component preview
Build a pagination component
Use pagination to break up content and spread it over numerous pages. This can help make large content sections easier to read and gives a person a sense of their position within the documents.
Coding and accessibility for pagination
Set up simple pagination
Use simple pagination for a smaller number of pages.
- Set the
display
attribute tosimple
. - Set the previous page’s URL with the
previous-href
attribute. - Set the previous page’s label with the
previous-label
attribute. - Set the next page’s URL with the
next-href
attribute. - Set the next page’s label with the
next-label
attribute.
Set up list styled pagination
Use list styled pagination when you are dealing with a larger number of pages.
- Set the
display
attribute tolist
. - Set the total number of pages in your sequence with the
total-pages
attribute using a numeric value. - Set the current or active page with the
current-page
attribute using a numeric value. - Opt to use the
url
attribute 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}}',
},
};
Get your code
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