GC Design System Components
Home Start to use Page templates overview Basic page Components overview Breadcrumbs Button Card Checkboxes Container Date input Date modified Details Error message Error summary Fieldset File uploader Footer Grid Header Heading Icon Input Language toggle Link Notice Pagination Radios Screenreader-only Search Select Side navigation Signature Stepper Text Textarea Theme and topic menu Top navigation CSS shortcuts overview Reset styles Responsive layout State Box sizing Container sizing Display Overflow Position Visibility Font Font family Font size Font style Font weight Line height Link colour Link size Link text decoration List style Text align Text colour Text overflow Text transform Word break Margin Padding Align content Align items Align self Flex Flex direction Flex grow Flex shrink Flex wrap Gap Grid columns Grid rows Justify content Justify items Justify self Order Place content Place items Place self Background colour Border colour Border radius Border style Border width Icon names Icon size Image Cursor Pointer events Transition Styles overview Design tokens Colour tokens Spacing tokens Typography tokens Contact us Get involved Find a demo

Pagination
<gcds-pagination>

Also called: page index, page navigation.

Pagination is a division of content into multiple linked pages.

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 to simple.
  • 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 to list.
  • 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.

  1. Explore by choosing different code values to generate the instance you want.

  2. Get the code and pull it into your environment.

  3. 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 account. You'll have access to the team's direct responses, progress made on your issue, and issues raised by others.

Give feedback Report an issue on GitHub
2024-07-15