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.
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.
{{ $examplePaginator->links('acun-ui::components.ui.pagination') }}
| Prop | Values |
|---|---|
view | acun-ui::components.ui.pagination |
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.
@php($singlePage = new \Illuminate\Pagination\LengthAwarePaginator(range(1, 3), 3, 25, 1, ['path' => '#']))
{{ $singlePage->links('acun-ui::components.ui.pagination') }}
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.
{{ $products->links() }}
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.
// app/Providers/AppServiceProvider.php
use Illuminate\Pagination\Paginator;
public function boot(): void
{
Paginator::defaultView('acun-ui::components.ui.pagination');
}
Props and slots
The values the component accepts.
| Prop | Default | Description |
|---|---|---|
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) |