Mushilu-San UI

Search components

PlaygroundStorybookGitHub
Navigation

Pagination

Moves through pages of results with previous, next and numbered controls.

Selector: mui-pagination

Import
import { Pagination } from '@mushilu-san/ui/navigation';
PreviewCode

Loading example…

Overview

Pagination renders a role="navigation" with previous and next buttons and page buttons. The current page is a two-way page model, and totalPages sets the range.

Long ranges collapse to ellipses around the current page. siblingCount sets how many pages show on each side of it.

When to use

  • Lists of results split across pages, such as search results or a table of records.
  • Any list where the user needs to jump to a page by number.

When not to use

  • A short list that fits on one screen.
  • An endless feed. Use a "Load more" button. Use Button instead.

Guidelines

Do

  • Show the total result count near the list so users know how many pages there are.
  • Keep the page the user is on in the URL when the list is shareable.

Don't

  • Do not hide pagination when there is only one page. Disable the controls instead.

Accessibility

Roles and attributes

ElementRoleNotes
hostnavigationaria-label from ariaLabel, default "Pagination".
previous / nextbuttonLabelled "Go to previous page" and "Go to next page". aria-disabled at the ends.
pagebuttonLabelled "Page N". aria-current="page" on the current page.

Keyboard

KeysAction
TabShiftTabMoves between the page controls.
EnterSpaceGoes to the focused page.
  • Ellipses are decorative and hidden from assistive technology.

API

Pagination

Selector: mui-pagination

NameTypeDefaultDescription
totalPagesrequirednumber— Total number of pages.
siblingCountnumber1 Number of page buttons shown on each side of the current page. Default `1`.
showFirstLastbooleantrue Shows the first and last page buttons next to the ellipses. Default `true`. Accepts attribute presence, e.g. <… showFirstLast>.
size'sm' | 'md' | 'lg''md' Button size: `sm`, `md` or `lg`. Default `md`.
variant'default' | 'outline''default' Visual style: `default` or `outline`. Default `default`.
ariaLabelstring'Pagination' Accessible name of the navigation landmark. Default `Pagination`.
NameTypeDefaultDescription
pagenumber1 Current page, starting at 1. Two-way bindable with `[(page)]`.

CSS parts

  • ::part(ellipsis)
  • ::part(item)
  • ::part(next)
  • ::part(page)
  • ::part(pagination)
  • ::part(prev)

Tokens

  • --mui-color-primary
  • --mui-color-primary-text
  • --mui-color-border
  • --mui-color-focus-ring
  • --mui-touch-target