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

List parts

The parts that build the panel's list pages: the toolbar, the filter button, the bulk selection bar, a sortable table and pagination.

zb:list-toolbar · zb:selection-bar · zb:table · zb:sortable-th zubazar/ui · free (MIT)

The kit only draws the look; search, sorting, selection and pagination must live in your own Livewire component.

Basic usage

Basic usage: view
BLADE

The simplest list is made of zb:list-toolbar (search on the left, actions on the right), zb:table and the pagination bar.

blade
<div class="space-y-4">
    <zb:list-toolbar>
        <zb:search name="list_search" placeholder="Product name or SKU" />
        <zb:slot:actions><zb:button>New Product</zb:button></zb:slot:actions>
    </zb:list-toolbar>
    <zb:table>
        <table class="ui-table"><thead><tr><th>Product Name</th><th>SKU</th></tr></thead><tbody><tr><td>Wireless headphones</td><td>WH-01</td></tr><tr><td>Mechanical keyboard</td><td>MK-04</td></tr></tbody></table>
    </zb:table>
    {{ $examplePaginator->links('zubazar-ui::components.ui.pagination') }}
</div>

Look

Look: view
BLADE

A full list page: the Filters panel opened with zb:filter-button (PRO), zb:selection-bar shown while something is selected, zb:sortable-th headers and pagination.

blade
<div class="space-y-4">
    <zb:list-toolbar>
        <zb:search name="list_search" placeholder="Product name or SKU" />
        <zb:slot:actions>
            <zb:filter-button drawer="catalog-listing-filters" :count="2" />
            <zb:button>New Product</zb:button>
        </zb:slot:actions>
    </zb:list-toolbar>

    <zb:selection-bar :count="2" clear-action="clearSelection">
        <zb:button variant="white" size="sm">Activate</zb:button>
        <zb:button variant="danger" size="sm">Delete</zb:button>
    </zb:selection-bar>

    <zb:table>
        <table class="ui-table">
            <thead>
                <tr>
                    <th class="w-10"><zb:checkbox id="list-all" aria-label="Select all" /></th>
                    <zb:sortable-th field="name" sort-field="name" sort-direction="asc">Product Name</zb:sortable-th>
                    <zb:sortable-th field="sku" sort-field="name" sort-direction="asc">SKU</zb:sortable-th>
                    <th class="text-center">Stock</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <tr><td><zb:checkbox id="list-1" checked /></td><td class="font-medium text-ink">Wireless headphones</td><td>WH-01</td><td class="text-center tabular-nums">312</td><td><zb:badge variant="success">Active</zb:badge></td></tr>
                <tr><td><zb:checkbox id="list-2" checked /></td><td class="font-medium text-ink">Mechanical keyboard</td><td>MK-04</td><td class="text-center tabular-nums">148</td><td><zb:badge variant="success">Active</zb:badge></td></tr>
                <tr><td><zb:checkbox id="list-3" /></td><td class="font-medium text-ink">USB-C charger</td><td>UC-02</td><td class="text-center tabular-nums">96</td><td><zb:badge variant="danger">Inactive</zb:badge></td></tr>
            </tbody>
        </table>
    </zb:table>

    {{ $examplePaginator->links('zubazar-ui::components.ui.pagination') }}
</div>

<zb:drawer name="catalog-listing-filters" docked title="Filters" compact>
    <zb:select name="list_status" :options="['' => 'All Statuses', '1' => 'Active', '0' => 'Inactive']" />
</zb:drawer>
PropValues
zb:list-toolbarDefault slot: search · actions slot: the buttons on the right
zb:filter-buttondrawer: name of the drawer to open · count: number of active filters · label: text (default Filters, in the app language)
zb:selection-barcount · all-matching · total · clear-action

Your Livewire component

PHP

WithPagination handles pagination and #[Url] the address bar; apply sorting only to the fields you allow.

php
use Livewire\Attributes\Url;
use Livewire\Component;
use Livewire\WithPagination;

new class extends Component
{
    use WithPagination;

    #[Url(as: 'q')]
    public string $search = '';

    #[Url(as: 'sort')]
    public string $sortField = 'name';

    #[Url(as: 'direction')]
    public string $sortDirection = 'asc';

    /** @var list<string> */
    public array $selected = [];

    public function sort(string $field): void
    {
        // Only the allowed fields; any other value from the address bar is ignored.
        if (! in_array($field, ['name', 'sku'], true)) {
            return;
        }

        $this->sortDirection = $this->sortField === $field && $this->sortDirection === 'asc' ? 'desc' : 'asc';
        $this->sortField = $field;
        $this->resetPage();
    }

    public function updatedSearch(): void
    {
        $this->resetPage();
        $this->selected = [];
    }

    public function clearSelection(): void
    {
        $this->selected = [];
    }

    public function with(): array
    {
        $field = in_array($this->sortField, ['name', 'sku'], true) ? $this->sortField : 'name';

        return [
            'products' => Product::query()
                ->when($this->search !== '', fn ($query) => $query->where('name', 'like', '%'.$this->search.'%'))
                ->orderBy($field, $this->sortDirection === 'desc' ? 'desc' : 'asc')
                ->paginate(25),
        ];
    }
};

Blade template

BLADE

Bind the search with wire:model; zb:sortable-th calls the method given as method, and zb:selection-bar the one given as clear-action.

blade
<zb:list-toolbar>
    <zb:search wire:model.live.debounce.400ms="search" placeholder="Product name" />
</zb:list-toolbar>

<zb:selection-bar :count="count($selected)" clear-action="clearSelection">
    <zb:button variant="danger" size="sm" wire:click="deleteSelectedProducts">Delete</zb:button>
</zb:selection-bar>

<zb:table>
    <table class="ui-table">
        <thead>
            <tr>
                <th class="w-10"></th>
                <zb:sortable-th field="name" method="sort" :sort-field="$sortField" :sort-direction="$sortDirection">Product name</zb:sortable-th>
                <zb:sortable-th field="sku" method="sort" :sort-field="$sortField" :sort-direction="$sortDirection">SKU</zb:sortable-th>
            </tr>
        </thead>
        <tbody>
            @foreach ($products as $product)
                <tr wire:key="product-{{ $product->id }}">
                    <td><zb:checkbox wire:model.live="selected" value="{{ $product->id }}" aria-label="{{ $product->name }} select" /></td>
                    <td>{{ $product->name }}</td>
                    <td>{{ $product->sku }}</td>
                </tr>
            @endforeach
        </tbody>
    </table>
</zb:table>

{{ $products->links('zubazar-ui::components.ui.pagination') }}

Props

The values the component takes. What are props and slots?

PropTypeDefaultDescription
zb:list-toolbar— — Search on the left, buttons in the `actions` slot
zb:search— — Your component's search property with `wire:model.live.debounce`
zb:filter-button— — PRO: opens the filter drawer; `count` is the number of active filters
zb:selection-bar— — `count`, `all-matching`, `total`; `clear-action` is the method that clears the selection (default clearSelection)
zb:sortable-th— — `field`, `sort-field`, `sort-direction`; `method` is called when clicked (default sortBy)
zb:table— — A card-style table container that scrolls sideways; put a table with the `ui-table` class inside
links('zubazar-ui::components.ui.pagination')— — Draws a Laravel paginator with the kit's pagination view

Developer notes

Events, hooks and details
  • Use these parts with the data table of your choice: your own Livewire component or a table package (List page guide).
  • The "Look" example has no Livewire, so clicks do not reach the server.
Zubazar UI · ZubazarDesigned for people.