Skip to content

Pagination

Content

In Material Design 3

Pagination shows where the user is among pages: a row of dots or numbers.

In Tesserae

Pagination is a view Tesserae ships (Pagination_View.tdl): previous and next arrows with the page numbers between them.

Page (from 1) is two-way: choosing another writes it back. Pages is how many there are. Compact shows "3 of 12" between the arrows instead of the numbers, and Dots shows a dot for each page, the current one primary, for a carousel (best under ten pages).

The first and last pages and the ones beside the current page always show, with an ellipsis for the stretch left out (up to seven pages show whole). The current page is a filled button, and each number is named "Page n" and marks the current one as the page. Previous is disabled on the first page and next on the last. Tab visits each control, and Enter or Space chooses. Not built: an items-per-page control, a count of all the items, and a jump-to field.

How it is built

A view Tesserae ships is a <Name>_View.tdl (what it takes and what it is made of) with a <Name>_Stylesheet.tdl (how it looks). Use it by name: Pagination { ... }. A file of the same name in your project replaces it.

Pagination

Page navigation (not Material 3 itself, which has page indicators and a pager): previous and next, and between them the page numbers with an ellipsis for the stretches left out, the current page filled. Page (two-way, from 1) is the page showing and Pages how many there are; the first, the last and the pages beside the current one always show. Compact is a "3 of 12" between the arrows, and Dots is a row of dots, one to a page, for a carousel. Previous is disabled on the first page and next on the last. Tab visits each control; Enter or Space chooses.

Parameter Type Default Meaning
Page int 1 The page showing, from 1; choosing another writes it back. Two-way: give it a bare reference and the view writes it back.
Pages int 1 How many pages there are.
Compact bool false Show '3 of 12' instead of the numbers.
Dots bool false Show a dot for each page instead of the numbers (best under ten pages).

Its parts, by name (a stylesheet rule's Part or Name addresses one): previous (IconButton), summary (Text), dot (Container), mark (Container), slot (Container), gap (Text), number (Button), next (IconButton).

Its look is in Pagination_Stylesheet.tdl.

Using it

Container {
  Name: results
  Style { Flex_Direction: vertical, Gap: 12, Width: 480, Height: 200 }
  Children {
    Pagination {
      Page: <| page |>
      Pages: <| total_pages |>
    }
    Pagination {
      Page: <| page |>
      Pages: <| total_pages |>
      Compact: true
    }
    Pagination {
      Page: <| page |>
      Pages: 5
      Dots: true
    }
  }
}

Using it in Python

from tess_ui.widgets import pagination

pages = pagination(app.window, 10, current=0)

Changing its look

To restyle it in your whole app, write rules for it in your app's stylesheet, or put <Name>_Stylesheet.tdl next to your views (or in Styles/); it is read only while the app uses the view. A rule names the widget and may narrow it by the properties it declares, a part and a state; the most specific rule wins, and a node's own Style beats every rule:

# Pagination_Stylesheet.tdl, or any stylesheet your app loads
Styles {
  Rule {
    Widget: Pagination
    Part: gap
    Style { Foreground: tertiary }
  }
}

See Component stylesheets.

See also