v0.0.2
Demos (demo panel, opens in a new tab)

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

Basic usage: view
BLADE

Pass the kit's view name to the links() method of a paginate() result.

blade
{{ $examplePaginator->links('zubazar-ui::components.ui.pagination') }}
PropValues
viewzubazar-ui::components.ui.pagination

Single page

Single page: view
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.

blade
@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.

blade
{{ $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.

php
// 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?

PropTypeDefaultDescription
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

Events, hooks and details
  • 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(), not Paginator::defaultView(), so pass the view name to links().
  • The page name can be changed (paginate(10, pageName: 'ordersPage')), so two lists on one page paginate separately.
Zubazar UI · ZubazarDesigned for people.