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
This component is in Zubazar UI Pro; Zubazar UI Pro brings Zubazar UI with it. Installing Zubazar UI Pro →
Product grid
The grid takes a collection of products and draws a zb:shop.product-card for each.
<zb:shop.product-grid :products="$products" />
Next to filters
In a list with a column of filters beside it, set columns="3": the grid stays at three columns on wide screens too.
<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
Each list on a page sets its own key-prefix; the default prefix is grid.
<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
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.
<zb:shop.product-grid :products="$products" view="list" />
An empty list
The grid draws nothing for an empty collection; when a search or the filters find nothing, show zb:shop.empty instead.
@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?
| Prop | Type | Default | Description |
|---|---|---|---|
products | — | — | The products: a collection or an array of Product; required |
columns | number | 4 | 4: a full-width page · 3: a list with filters beside it |
key-prefix | — | grid | The Livewire key prefix passed to the cards; give each list on a page its own |
view | — | grid | grid · 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
- 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-prefixvalues keep the keys of the cards' "Add to cart" components apart.