Pagination
The pager bar used under grids and tables, page-size select, "Showing X to Y of Z Records" text, page-count text and the prev/next/page-number controls. Each of the first three blocks can be hidden independently with showPageSize, showRecordsText and showPageCount, all default to true, so nothing already using bk-pagination changes unless it opts in.
Preview
A working preview of Pagination in the Brickclay style. Try it.
Interactive playground
Rows per page
Showing 1 to 25 of 237 Records
1 - 2 of 10
-
- 1
- 2
Both on: showPageSize=true. Both off: showPageSize=false. Just one off: the object form, e.g. { label: false }, see the generated markup below.
Applied in two places: the flex row carrying justify-between (not the outer padding/border wrapper), controls arrangement among the top-level blocks, and the nav itself, which only has room to act on once it's the sole block left (it grows to fill the row), there the same class spreads its own two children (page count vs. page numbers) instead. Toggle off showPageSize and showRecordsText, then try justify-between here.
total: 237, pageSize: 25, activePage: 1
<bk-pagination [total]="total" [pageSize]="pageSize" [activePage]="activePage" (pageChanged)="onPageChanged($event)" (changePageSize)="onPageSizeChanged($event)"> </bk-pagination>
Event log
Change the page or the page size to see emitted events.
Examples
Default, all three blocks shown
Showing 1 to 25 of 120 Records
1 - 2 of 5
[showPageSize]="false"
"Rows per page" hidden. With two blocks left, justify-between already pins the pager to the right on its own.
[showPageSize]="false" + customClass="justify-around"
Same two blocks as above (records text + nav), but customClass swaps the row's default justify-between for justify-around, each block also gets breathing room from its own edge, pushing the two further apart than the default edge-to-edge placement.
[showPageSize]="{ label: false }"
"Rows per page" text hidden, select kept, showPageSize also accepts { label?, input? } for hiding just one half.
[showPageSize]="{ input: false }"
Select hidden, "Rows per page" text kept on its own.
[showRecordsText]="false"
"Showing X to Y of Z Records" text hidden.
[showPageCount]="false"
"N-M of P" page-count text hidden; prev/next/page-number controls stay.
Compact, all three off, e.g. a modal footer
Only the nav (prev/next/page numbers) remains. With a single block left, justify-between has nothing to distribute against and the nav sits flush left, pass customClass="justify-end" (applied to the same flex row justify-between is on) to pin it right again, or justify-center to center it.
Page size + records off, page count on, spread page count from page numbers
Nav is the only block left, so it grows to fill the row, customClass="justify-between" now acts on nav's own two children instead, pushing the "N-M of P" text away from the prev/next/page-number controls rather than leaving them bunched together at the left edge.
Usage
total / pageSize / activePage drive the page count and the visible window; pageChanged and changePageSize report interaction back.
<bk-pagination [total]="total" [pageSize]="pageSize" [activePage]="activePage" (pageChanged)="onPageChanged($event)" (changePageSize)="onPageSizeChanged($event)"> </bk-pagination> // Hide any of the three blocks independently - each defaults to true, so // nothing already using bk-pagination changes unless it opts in. With only // the nav left, justify-between has nothing to distribute against and it // sits flush left - customClass lands on that same flex row, so pass // "justify-end" (or "justify-center") to reclaim its position: <bk-pagination [total]="total" [pageSize]="pageSize" [activePage]="activePage" [showPageSize]="false" [showRecordsText]="false" [showPageCount]="false" customClass="justify-end"> </bk-pagination>
API reference
Inputs <bk-pagination>
| Name | Type | Default | Description |
|---|---|---|---|
total | number | 0 | Full row count. |
pageSize | number | 10 | Rows per page. The select offers 25/50/75/100. |
activePage | number | 1 | Current page, 1-based. |
showPageSize | boolean | { label?, input? } | true | Gates the "Rows per page" block. A boolean shows/hides the label and the bk-select together; pass an object to hide just one, e.g. { label: false } keeps the select but drops the "Rows per page" text. |
showRecordsText | boolean | true | Gates the "Showing X to Y of Z Records" text. |
showPageCount | boolean | true | Gates the "N-M of P" page-count text. The prev/next/page-number controls are unaffected. |
customClass | string | '' | Applied to both the flex row carrying justify-between (not the outer padding/border wrapper) and to the nav itself, the nav only grows to fill the row (so its own justify-* has room to act) when it's the sole visible block. |
Outputs <bk-pagination>
| Name | Payload | Fires when |
|---|---|---|
pageChanged | number | A page number, or a prev/next control, is clicked. |
changePageSize | number | The "Rows per page" select changes. Resets to page 1. |