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.
components.ui.pagination zubazar/ui · free (MIT)
Basic usage
BLADE
Pass the kit's view name to the links() method of a paginate() result.
{{ $examplePaginator->links('zubazar-ui::components.ui.pagination') }}
| Prop | Values |
|---|---|
view | zubazar-ui::components.ui.pagination |
Single page
BLADE
The bar stays visible with a single page and even with no results, so the page does not jump when a filter empties the list.
@php($singlePage = new \Illuminate\Pagination\LengthAwarePaginator(range(1, 3), 3, 25, 1, ['path' => '#']))
{{ $singlePage->links('zubazar-ui::components.ui.pagination') }}
On list pages
BLADE
Use WithPagination in your Livewire component and draw the paginator with the kit's view; the buttons work without a page reload.
{{ $products->links('zubazar-ui::components.ui.pagination') }}
Application-wide
PHP
To use the view everywhere on pages outside Livewire (controller + Blade), register it as the default view.
// app/Providers/AppServiceProvider.php
use Illuminate\Pagination\Paginator;
public function boot(): void
{
Paginator::defaultView('zubazar-ui::components.ui.pagination');
}
Props
The values the component takes. What are props and slots?
| Prop | Type | Default | Description |
|---|---|---|---|
paginator | — | — | paginate(): summary, page numbers and arrows · simplePaginate(): summary without the total and arrows · cursorPaginate(): arrows only |
Livewire methods | — | — | previousPage · nextPage · gotoPage(n) · setPage (cursor); without Livewire the buttons work with href |
translations | — | — | Showing :first to :last of :total results · Showing :first to :last · No results · Previous · Next (lang/tr.json) |
Developer notes
- In Livewire components it works without a page reload, without Livewire with regular links; when the top of the list is above the screen, changing the page scrolls back to it.
- Livewire components use their own
paginationView(), notPaginator::defaultView(), so pass the view name tolinks(). - The page name can be changed (
paginate(10, pageName: 'ordersPage')), so two lists on one page paginate separately.