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

Product grid

The grid of product cards: two columns on phones, three on tablets and four on wide screens.

zb:shop.product-grid zubazar/ui-pro

PRO

This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →

Product grid

Product grid: view
BLADE

The grid takes a collection of products and draws a zb:shop.product-card for each.

blade
<zb:shop.product-grid :products="$products" />

Next to filters

Next to filters: view
BLADE

In a list with a column of filters beside it, set columns="3": the grid stays at three columns on wide screens too.

blade
<div class="grid gap-8 lg:grid-cols-[14rem_1fr]">
    <aside class="h-fit">
        <h2 class="mb-4 text-sm font-semibold text-ink">Filters</h2>
        <div class="flex flex-col gap-3 border-y border-line py-4">
            <zb:checkbox name="sale" label="On sale" />
            <zb:checkbox name="new" label="New arrivals" />
            <zb:checkbox name="in_stock" label="In stock" />
        </div>
    </aside>
    <zb:shop.product-grid :products="$products" key-prefix="list" columns="3" class="min-w-0" />
</div>

Several lists on a page

Several lists on a page: view
BLADE

Each list on a page sets its own key-prefix; the default prefix is grid.

blade
<zb:shop.section-heading eyebrow="Showcase" title="This week's favourites" :href="route('web.products.index')" link-label="All products" />
<zb:shop.product-grid :products="$featured" key-prefix="featured" class="mt-6" />

List view

List view: view
BLADE

view="list" draws the cards lying down: the picture on the left at the card's height, the name, rating, short description and price beside it. Two columns in a wide space; on a phone the card stands up as usual.

blade
<zb:shop.product-grid :products="$products" view="list" />

An empty list

An empty list: view
BLADE

The grid draws nothing for an empty collection; when a search or the filters find nothing, show zb:shop.empty instead.

blade
@if ($products->isEmpty())
    <zb:shop.empty title="We couldn't find what you're looking for" description="Try fewer filters or search with another word.">
        <zb:slot:icon><zb:icon name="magnifying-glass" size="10" /></zb:slot:icon>
        <zb:slot:action><zb:button :href="route('web.products.index')" variant="white">Clear filters</zb:button></zb:slot:action>
    </zb:shop.empty>
@else
    <zb:shop.product-grid :products="$products" key-prefix="list" columns="3" />
@endif

Props

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

PropTypeDefaultDescription
products— — The products: a collection or an array of Product; required
columnsnumber44: a full-width page · 3: a list with filters beside it
key-prefix—gridThe Livewire key prefix passed to the cards; give each list on a page its own
view—gridgrid · list (the cards drawn with layout="list"; one column, two from 58rem wide; `columns="1"` keeps one). On the product and category lists the grid/list buttons choose it with `?view=list`

Developer notes

Events, hooks and details
  • The home page showcases, the product and category lists, the related products on the product page and the suggestions in the cart use this grid.
  • The default four columns are for full-width pages; the fourth column comes on wide screens (xl).
  • A product can be in two lists on the same page (the highlights and the sale items, say); separate key-prefix values keep the keys of the cards' "Add to cart" components apart.
Zubazar UI · ZubazarDesigned for people.