Pagination
Pagination is a legacy migration surface: the Rust crate's page bar — a previous arrow, the page numbers (a plain run up to seven pages, a window with ellipsis buttons beyond that), a next arrow, and optionally an "x–y of n" read-out and a page-size selector. It renders no rows and fetches nothing: the host says how many items there are, the bar reports which page was asked for.
PaginationButton is the one-page button the bar is built from, and it has no page of its own; this page documents it with the bar that arranges it. It renders either an arrow, a number, or an ellipsis and wraps the result in the glow that gives the bar its press highlight — and it is the one member of this family that is not reachable from rsx! in any spelling (see "PaginationButton" below).
New code should page through HkCardList, which owns the whole list surface — the rows, the total, the empty state and its own pager — rather than mounting a bar beside a hand-drawn table or list.
- Reach for Pagination while migrating a Rust page that keeps its rows and its pager apart; on a new list use HkCardList.
- The bar's own pages are plain text past this component; what each page contains is the host's business.
- A scroll-position read-out rather than pages is ScrollProgressDock; a "load more" tail is LoadMore.
Import
use *; // Pagination, PaginationButton, PaginationButtonContent
use *; // PaginationProps, PaginationButtonProps, rsx!, VNode
Pagination is a plain function, Pagination(PaginationProps { … }). Inside rsx! current defaults to 1, page_size to 10, show_size_changer and show_total to false, page_size_options to [10, 20, 50, 100], class to "", the two handlers to None and instance_id to None; total is the one field without a declared default (the macro fills it). PaginationProps and PaginationButtonProps are both in the prelude; PaginationButtonContent is not, so a host that names the enum takes it from hikari_components.
Pages and the window
The page count is derived from total and page_size — (total - 1) / page_size + 1, with 0 items counting as one page. Up to seven pages the bar prints each number as a button.hk-pagination-item, the current one also carrying hk-pagination-active; past seven it prints 1, a jump ellipsis when the window has moved right, the current page with its two neighbours, a second ellipsis when pages remain to the right, and the last number.
current seeds the bar; the bar keeps its own page signal after that. The previous arrow is disabled at page 1, the next one at the last page, and both are Arrow glyphs inside the same button shell; each button — arrows included — is wrapped in a Glow so the primary spotlight follows the press.
Total, page size, and the ellipsis
show_total prepends div.hk-pagination-total holding the current window as text; show_size_changer prepends div.hk-pagination-size-selector holding a select.hk-pagination-size-select whose options come from page_size_options. Changing the size recomputes the page count and clamps the page if it now overshoots, then reports through on_size_change.
The mirror prints two of those as literal text. div.hk-pagination-total renders the string {_start}-{_end} of {total_items} and each size option renders {size} / page — a mixed string is passed through verbatim rather than interpolated, so a reader sees the braces. The same applies to the jump popover's Page 1 to {total_pages} line, which additionally only exists inside an open ellipsis branch and so never appears in a snapshot.
An ellipsis button is not dead text: it opens a small popover with a number field, an arrow button and a "Page 1 to n" line, and jumps on confirm. The two ellipsis anchors share one jump state per instance, which is why instance_id exists: two bars with the same (default) id write the same two DOM ids and open the same layer — give each bar its own.
What a press reports
on_change is an EventHandler<u32> fired with the page a press asked for (the arrows, a number, or a jump); on_size_change is an EventHandler<u32> fired with the new page size. The bar advances its own signal first, so a host that ignores the callback still sees the local page move — feed current back only when the data arrives. A snapshot is declarative: the marks in the samples come from current alone.
PaginationButton
PaginationButton is the button shell the bar's controls share: a div.hk-pagination-item (plus hk-pagination-active when active) with the fixed 28px inline box, holding an Arrow, a Text or a literal "..." from PaginationButtonContent, wrapped in Glow unless disabled. Its glow_blur / glow_color / glow_intensity tune that glow.
It has no markup example here because an rsx! block cannot build it at all: the field-by-field form the macro emits needs Default on the props struct, and PaginationButtonProps derives only Clone, PartialEq, Props, so PaginationButton { … } fails. The three spellings tried against cargo build in this repository's own documentation workspace, and what each reported:
PaginationButton { content: …, onclick: … }
error[E0277]: the trait bound `hikari_components::PaginationButtonProps: std::default::Default` is not satisfied
PaginationButton { content: …, onclick: …, ..some_props } // a struct value spread in
error[E0560]: struct `hikari_components::PaginationButtonProps` has no field named `children`
error[E0277]: the trait bound `…PaginationButtonProps: std::default::Default` is not satisfied
rsx! { PaginationButton(props) } // call syntax inside a block
error: unexpected token
The direct call works, outside rsx! — PaginationButton(PaginationButtonProps { … }) returns the element — but the fence has to end in an rsx! root, so a docs example cannot show it. Two things about that call are worth knowing if you migrate the code by hand: onclick is a bare EventHandler<MouseEvent> (not Option<…>, unlike every other handler in this family), so it is written onclick: event_handler(|_event: MouseEvent| ()); and the bar itself does not use this component — Pagination builds its own button.hk-pagination-item elements, which is why the bar's controls are real buttons and this one's box is a div.
API
Rust
Props — Pagination
| Prop | Type | Default | Description |
|---|---|---|---|
| instance_id | Option<String> | None | Instance identity for the jump layer (ids + shared state). |
| current | u32 | 1 | — |
| total | u32 | 0 | — |
| page_size | u32 | 10 | — |
| show_size_changer | bool | false | — |
| show_total | bool | false | — |
| page_size_options | Vec<u32> | vec![10, 20, 50, 100] | — |
| class | String | "" | — |
| on_change | Option<EventHandler<u32>> | None | — |
| on_size_change | Option<EventHandler<u32>> | None | — |
Props — PaginationButton
| Prop | Type | Default | Description |
|---|---|---|---|
| content | PaginationButtonContent | Default::default() | — |
| active | bool | false | — |
| disabled | bool | false | — |
| class | String | "" | — |
| onclick | EventHandler<MouseEvent> | Default::default() | — |
| glow_blur | GlowBlur | GlowBlur::Medium | — |
| glow_color | GlowColor | GlowColor::Primary | — |
| glow_intensity | GlowIntensity | GlowIntensity::Dim | — |
Accessibility
- The bar's page controls are real <button> elements, so they are in the tab order and Enter / Space activates them; the disabled arrows are genuinely disabled, which removes them from the tab order and tells a screen reader they are unavailable. (The standalone PaginationButton, if a host does use it, emits a div with a click handler instead — no role, no tab stop.)
- Nothing marks the current page as such to assistive technology: hk-pagination-active is a class, and no aria-current="page" (or aria-pressed) is written, so the selected page is announced like every other number.
- The bar has no landmark, no list and no group role, and the arrows have no accessible name: the button's only content is an SVG glyph with no aria-label and no title, so a screen reader reaches an unnamed button for previous and next.
- The ellipsis buttons are <button> elements holding a dots icon, likewise unnamed; they open a popover whose contents (a number field, a submit arrow, a range line) sit outside the button's name.
- The size selector is a native <select> with options spelled "<n> / page"; it has no associated <label>, so the control is announced without its purpose beyond the option text.
- The total read-out is plain text with no label, so "51-100 of 250" is read as a number run rather than as a range of a total.
Related components
- HkCardList — the Vue list that owns rows, total, empty state and its pager; the replacement for a bar mounted beside loose rows.
- LoadMore and InfiniteTail — growing a list in place instead of paging it.
- Cell and Table — the rows a pager drives, and the Rust table they were written for.
- ScrollProgressDock — where you are in a long list, rather than which page you are on.