Navigation

Pagination

The page links under a list or a table: a "Showing 1 to 10 of 97 results" summary, previous, next, first and last buttons, and the page numbers with gaps. It takes a Laravel paginator, and inside a Livewire component with WithPagination it changes page without a reload.

tk:pagination renders the inner tags itself; they are written by hand only inside its results and links slots.

Total: 0 results

Blade

A line on top, then "Showing 1 to 10 of 97 results" at the start and the links at the end: first, previous, the page numbers (on long lists, the ones around the current page plus the first and last two, with gaps between), next and last. The current page is highlighted and disabled. Inside Livewire, a click changes the page and scrolls the page to the top; outside it, the links are plain URLs.

Choosing the page size #

A select with 10, 25 and 50 next to the summary. Inside Livewire it is bound to $perPage (or to per-page-name); outside it, it reloads the page with ?perPage=25. Either way a new size goes back to page 1.

On this page:

Total: 0 results

Blade

Simple and cursor paginators #

With simplePaginate() or cursorPaginate() there is no total, so only the previous and next buttons are shown. When everything fits in one page, a "Total: 3 results" line is shown instead.

On this page:

Total: 0 results

Blade

A plain collection #

A collection or array that is not paginated shows only its total, here without the line on top and with less padding: useful under a table that lists everything.

Total: 3 results

Blade

Custom layout #

results replaces everything under the line: here a "Page 5 of 20" text and the previous and next buttons, which read the paginator from the pagination around them. links replaces only the page numbers and keeps the summary and the arrows:

Each element is an array of page numbers to URLs, or a '...' string for a gap. Buttons written in these slots do not move the focus or scroll to scrollTo when clicked, and the page numbers are not hidden in a narrow pagination: they wrap onto more lines when they don't fit.

Page 1 of 1

Total: 0 results

Blade

Sizes and density #

size goes from xs to 3xl; dense uses less padding and :each-side limits the page numbers around the current one.

Total: 0 results

Total: 0 results

Total: 0 results

Blade

Without some parts #

:total="false" hides the summary; :first-page and :last-page set to false remove the end buttons.

Total: 0 results

Blade

Customization #

Prefixed attributes reach the parts: page: each number, prev-page: and next-page: the arrows, results: the summary.

Total: 0 results

Blade

Reference

tk:pagination
├── tk:pagination.first-page
├── tk:pagination.prev-page
├── tk:pagination.page ...
├── tk:pagination.next-page
├── tk:pagination.last-page
└── tk:pagination.per-page

tk:pagination

Prop Type Default Description
paginator Paginator | Collection | array required The paginator (paginate(), simplePaginate(), cursorPaginate()), or a collection to show the total of.
perPage array null Page sizes to choose from in a select.
perPageName string perPage The Livewire property, or the query string key, the page size is bound to.
total bool true false hides the results summary.
firstPage bool true false removes the first page button.
lastPage bool true false removes the last page button.
eachSide int the paginator's How many page numbers are shown on each side of the current one. Defaults to the paginator's onEachSide (3 unless set with ->onEachSide()).
scrollTo string | false body A selector of the element scrolled into view when a pagination button is clicked inside Livewire: the closest ancestor that matches it, or else the first match on the page. false keeps the scroll.
separator bool true Draws a line above the pagination.
dense bool false Less padding, as in a dense table.
size string md xs, sm, md, lg, xl, 2xl or 3xl.

dense is also inherited from a tk:table with dense, which renders the pagination under it.

Slots

Slot Description
results Replaces the content inside the padded container (the line on top stays): a function receiving the paginator, for a layout of your own, written with @scope('results', $paginator).
links Replaces the page numbers: a function receiving the paginator and the elements (page arrays and ... gaps), written with @scope('links', $paginator, $elements).

Prefixes

Prefix Goes to
container: The element with the padding.
nav: The <nav>.
summary:, results:, total: The summary area, the "Showing..." text, the short total shown in a narrow pagination.
per-page: The page size select.
pages: The group of buttons.
page:, dots: Each page number, each gap.
first-page:, prev-page:, next-page:, last-page: The arrow buttons (prev-page:icon="mdi:arrow-left").
separator: The line on top.

tk:pagination.first-page, .prev-page, .next-page and .last-page

tk:buttons with an icon and a tooltip ("Previous page"...), disabled at the ends. icon and tooltip change the arrow and its text; they also take the other element props.

tk:pagination.page and tk:pagination.per-page

A page number button (page), and the page size select (options, name).

Customization

Classes and attributes on the tag go to the outer element. To reach the parts, prefix the attribute (listed in the Reference above).

blade

Accessibility

A <nav> named "Pagination navigation". The current page has aria-current="page"; each button has a name ("Go to page 3", "Next page"); the disabled ends have aria-disabled. The page size select is named "Items per page". The <nav> has tabindex="-1": a click on a pagination button moves the focus to it, since the pressed button is disabled while the page loads, and Tab continues from there.

Behavior notes

  • The breakpoints follow the width of the pagination, not of the screen (container queries): below 56rem the page numbers and the gaps are hidden, and below 36rem the first and last buttons too, leaving the previous and next buttons and a short "Total: 97 results". The buttons stay on one line and the text wraps beside them. The pagination takes the full width of its parent (w-full); in a flex row, give it the width it should use (class="flex-1").
  • Inside Livewire the buttons are disabled while the page changes, so a second click does not skip a page.
  • With a single page, only a "Total: 3 results" line is shown.
  • Inside Livewire, WithPagination keeps the page number in the query string; the page size stays in the component unless $perPage has #[Url] (#[Url] public int $perPage = 10;).