EN
Getting started
33 · UI elements

Pagination

A ready-made view for the Laravel paginator: a "Showing 1 to 6 of 48 results" summary on the left, previous/next and page numbers on the right. In Livewire components it works without reloading the page; without Livewire it uses regular links.

components.ui.pagination
01

Basic usage

Pass the view name to the links() method of the paginator returned by paginate(). The active page is highlighted in the main color; on the first and last page, the corresponding arrow button is disabled.

LIVE EXAMPLE
{{ $examplePaginator->links('acun-ui::components.ui.pagination') }}
PropValues
viewacun-ui::components.ui.pagination
02

Single page

Even when the results fit on one page, the bar stays visible; the arrow buttons are disabled and "1" is shown as active. This way the bar does not suddenly disappear when a filter narrows the results. When there are no results at all (total() is 0), the bar is not rendered.

LIVE EXAMPLE
@php($singlePage = new \Illuminate\Pagination\LengthAwarePaginator(range(1, 3), 3, 25, 1, ['path' => '#']))

{{ $singlePage->links('acun-ui::components.ui.pagination') }}
03

On list pages

In components that use WithListing, you do not need to write the view name; the trait picks this view with paginationView(). The buttons call the previousPage, nextPage and gotoPage methods.

BLADE
{{ $products->links() }}
04

Application-wide

To use the same view everywhere on pages outside Livewire (controller + Blade), register it as the default view. Livewire components do not use this setting; they use their own paginationView() value.

PHP
// app/Providers/AppServiceProvider.php
use Illuminate\Pagination\Paginator;

public function boot(): void
{
    Paginator::defaultView('acun-ui::components.ui.pagination');
}
API

Props and slots

The values the component accepts.

PropDefaultDescription
paginator — The result of paginate() (LengthAwarePaginator); it needs total(), so it cannot be used with simplePaginate() or cursorPaginate()
Livewire methods — previousPage · nextPage · gotoPage(n); without Livewire the buttons work with href
translations — Showing · to · of · results · Previous · Next (lang/tr.json)
Acun UI · PaginationDetailed usage and examples