Navigation

Pagination

Navigate between pages of content.

Rust
1use herogpui::components::pagination::Pagination;

Usage

Rust
1use herogpui::prelude::Pagination;
2
3Pagination::new("pagination-main", page, 10)
4    .on_change(usize_cb(cx.listener(|this, p: &usize, _, cx| {
5        this.pagination_page = *p;
6        cx.notify();
7    })))

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

Pagination

Pagination is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Pagination uses.

Styling

Pagination styling
StyleDescription
flex row + items_center + justify_between + gap(px(16.))Responsive root layout.
flex + gap(px(8.)) + cell_text + cell_leading + mutedSummary text follows the size-specific 12/16, 14/20 and 16/24 font/line-height pairs.
row flex + items_center + gap(px(4.))Link-row layout.
implicit direct childOne compound item wrapper.
cell Size::Md 32px + control_radius + text_sizeDefault link geometry and typography.
instant active refinements; press geometry has no timelineLink state interpolation.
hover_bg / pressed_bg = colors.default.hover()Shared hover and pressed fill.
active branch default.color + shared hover/pressedTertiary-button active-page treatment.
size(cell) + cell_text + colors.mutedEllipsis geometry and colour.
content width + gap(px(6.)) + nav_padding 10pxPrevious and Next width, gap and padding.
Size::Sm => 28px / 12px / PRESSED_SCALE_SUBTLESmall link variant.
Size::Sm => nav_padding px(8.)Small navigation padding.
Size::Lg => 36px / 16px / PRESSED_SCALE_FIRMLarge link variant.
Size::Lg => nav_padding px(12.)Large navigation padding.

API reference

Builders

Pagination builders
BuilderTypeDefaultDescription
size(Size)SizeSize::MdSize of the pagination items.
new(id, page, total)id, page, totalPagination parts; the GPUI port generates the compound structure.
summary(text)textSummary content such as a visible item range.
link(render)boolfalseMarks the current page and is handed to the link render closure.
disabled_keys(keys)boolfalseDisables one page link by page number.
on_change(callback)Fn(e: ClickEvent) -> ()Reports a normalized pointer or keyboard press with its page number.
previous_icon(icon)iconDefault chevron SVGCustom icon replacing the previous chevron.
next_icon(icon)iconDefault chevron SVGCustom icon replacing the next chevron.

Parts

Pagination parts
PartDescription
PaginationRoot page-navigation container.
PaginationOptional summary before the links.
PaginationContainer for navigation items.
PaginationImplicit wrapper around one item.
PaginationFocusable page-number button.
PaginationButton targeting the previous page.
PaginationReplaceable previous-page icon.
PaginationButton targeting the next page.
PaginationReplaceable next-page icon.
PaginationNon-interactive omitted-page marker.

States

Pagination states
BuilderStateDescription
n == page + link(page, active)Active pageCurrent page with tertiary-button fill.
hover(default.hover())HoveredEnabled link or nav-button hover fill.
tab_stop_handle + with_focus_ringFocusedKeyboard focus ring.
is_disabled / disabled_keys gatesDisabledNo press or tab stop, with disabled opacity.
anim::pressed / pressed_with_backgroundPressedSize-specific scale and default-hover fill.