component
Pagination
Moving through a long list a page at a time. Back and forward buttons with where you are between them.
Try it
Every variant
Defaultimport { Pagination } from 'rost/components/pagination/Pagination'
<Pagination page={page} pages={pages} onChange={setPage} /> src/components/pagination/Pagination.tsx
import type { HTMLAttributes } from 'react'
import { IconButton } from '../icon-button/IconButton'
import { Icon } from '../icon/Icon'
import './pagination.css'
export interface PaginationProps extends Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
/** The page shown, from 1. */
readonly page: number
/** How many there are. */
readonly pages: number
/** Called with the page to show. */
readonly onChange?: (page: number) => void
}
const b = 'rost-pagination'
/**
* Back, where you are, forward. The buttons are disabled at either end.
* Built from contracts/pagination.contract.yaml.
*/
export function Pagination({ page, pages, onChange, className, ...rest }: PaginationProps) {
return (
<nav aria-label="Pagination" className={[b, className].filter(Boolean).join(' ')} {...rest}>
<IconButton className={`${b}__previous`} variant="secondary" aria-label="Previous page" disabled={page <= 1} onClick={() => onChange?.(page - 1)} />
<span className={`${b}__label`} aria-live="polite">Page {page} of {pages}</span>
<IconButton className={`${b}__next`} variant="secondary" aria-label="Next page" disabled={page >= pages} icon={<Icon name="arrow-right" size="small" />} onClick={() => onChange?.(page + 1)} />
</nav>
)
}
The source for everything on this page: contracts/pagination.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: pagination
name: Pagination
kind: component
status: review
summary: Moving through a long list a page at a time. Back and forward buttons with where you are between them.
category: navigation
related: [ table, icon-button ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "742:43"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=742-43
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
page: { type: number, required: true, notes: "The page shown, from 1." }
pages: { type: number, required: true, notes: "How many there are." }
elements:
root:
notes: "A `<nav aria-label=\"Pagination\">`: the back button, where you are, the forward button, 8px apart."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
gap: { token: spacing/gap/small, value: 8px }
previous:
notes: "An IconButton, Secondary, with its own arrow-left. Disabled on the first page."
styles:
flex-shrink: { value: "0", assert: false }
label:
notes: "\"Page 3 of 12\" in paragraph type, the secondary text colour, 8px clear of the buttons."
styles:
padding-left: { token: spacing/gap/small, value: 8px }
padding-right: { token: spacing/gap/small, value: 8px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: pagination/label, value: "#d3d9d5" }
white-space: { value: nowrap, assert: false }
next:
notes: "An IconButton, Secondary, with Rost's arrow-right Icon. Disabled on the last page."
styles:
flex-shrink: { value: "0", assert: false }
guidance:
status: proposed
use:
- title: Long lists
text: "Invoices, transactions, clients: anything longer than a screen where the order matters and people go back and forth."
avoid:
- title: Short lists
text: "Under fifty rows, show them all."
- title: Feeds
text: "Something people scroll through once. Load more as they reach the end."
behaviour: "Back, where you are, forward. I left out page numbers to jump to: in the apps people go one page at a time, and \"Page 3 of 12\" says enough. The buttons are disabled at either end."
accessibility:
element: "`<nav aria-label=\"Pagination\">`, with two IconButtons labelled Previous page and Next page."
name: "The buttons by what they do. The label says where you are, and `aria-live` reads the new page when it changes."
keyboard: "Tab reaches the buttons; Enter or Space turns the page."
colour: "The label is 11:1 on the dark page."
content: "\"Page 3 of 12\", in numbers."
Install
npx github:Runceanu/rost add pagination It lands in src/rost/pagination/, with what it needs and its contract. Install has the rest.
When to use
Long lists
Invoices, transactions, clients: anything longer than a screen where the order matters and people go back and forth.
When not to use
Short lists
Under fifty rows, show them all.
Feeds
Something people scroll through once. Load more as they reach the end.
Behaviour
Back, where you are, forward. I left out page numbers to jump to: in the apps people go one page at a time, and "Page 3 of 12" says enough. The buttons are disabled at either end.
Accessibility
- Element
<nav aria-label="Pagination">, with two IconButtons labelled Previous page and Next page. - Name
The buttons by what they do. The label says where you are, and
aria-livereads the new page when it changes. - Keyboard
Tab reaches the buttons; Enter or Space turns the page.
- Colour
The label is 11:1 on the dark page.
Content
"Page 3 of 12", in numbers.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
page | number | | |
pages | number | | |
Values
Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.
Never changes
root
-
gap8pxspacing/gap/small
displayinline-flex · align-itemscenter
previous
flex-shrink0
label
-
padding-left8pxspacing/gap/small -
padding-right8pxspacing/gap/small -
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#d3d9d5pagination/label
white-spacenowrap
next
flex-shrink0