---
title: Pagination
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Pagination } from '@telus-uds/components-web'
import { Pagination as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# Pagination

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D1844%253A10622" />

```jsx live
<Pagination>
  <Pagination.PageButton href="#test" hrefAttrs={{ target: '_blank' }} />
  <Pagination.PageButton onPress={() => {}} isActive />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
</Pagination>
```

## Introduction

Pagination can be used to enable a user to page through local page content or via links.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

- Pagination component accepts one or multiple Pagination.PageButton components as
  children and renders all or some of them (replacing the missing part with an ellipsis
  when there are too many pages available).
- Use `onPress` prop of the Pagination.PageButton component to handle the navigation.
- Alternatively, you can use the `href` and `hrefAttrs` props of the Pagination.PageButton
  for browser-based navigation.
- Use the `isActive` prop of the Pagination.PageButton component to indicate the button
  corresponding to the current page.
- Use `copy` prop (on both Pagination and Pagination.PageButton components) to specify
  the language of the labels or provide a custom dictionary.

### Accessibility

The Pagination component itself does not accept any accessibility attributes.
Pagination.PageButton, however, accepts standard accessibility props, including the ones
that are specific to the `button` role. By default accessibility role is set to `'button'`
(or to `link` if `href` prop is set) and the accessibility label is based on the value of
the `label` prop.

### Platform considerations

<AvailableOnBoth />

Keep in mind though that this is a responsive component: it displays less buttons and
visually hides the text for Previous and Next buttons when displayed in XS and SM viewports.

## Props

### Pagination

<PropsTable base={BaseDocs} />

### Pagination.PageButton

<PropsTable base={BaseDocs.PageButton} />

## Tokens

In exceptional circumstances, the following tokens can be passed to these components to override their default styles. **Do not do this unless absolutely necessary.** [Read more about overriding styles.](/develop/overriding-styles)

### Pagination

<TokensTable base={BaseDocs} component="Pagination" showDisclaimer={false} />

## Variants

### Hide button labels

By default, "Previous" and "Next" buttons are being rendered with labels on larger screens and without on the smaller ones.
You can override this behavior by setting the `compact` property under `sideButtonVariant` to `true`, in which case the only
the arrows and not the labels will be rendered:

```jsx live
<Pagination sideButtonVariant={{ compact: true }}>
  <Pagination.PageButton href="#test" hrefAttrs={{ target: '_blank' }} />
  <Pagination.PageButton onPress={() => {}} isActive />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
</Pagination>
```

### Number of pages to display

- You can override the amount of pages being displayed by setting the `numberOfPagesBeforeEllipsis` property to the desired number of pages to display.

- _Note:_ Value must be greater than 1 and less than the total number of pages, if other value is provided the default 4 + the index page (first element) will be display.

```jsx live
<Pagination sideButtonVariant={{ compact: true }} numberOfPagesBeforeEllipsis={1}>
  <Pagination.PageButton href="#test" hrefAttrs={{ target: '_blank' }} isActive />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
  <Pagination.PageButton onPress={() => {}} />
</Pagination>
```

## Feedback

<Feedback component="Pagination" />
