Product Listing
Shop grids — a sort/results toolbar above a responsive grid of product cards with sale badge, rating and add-to-cart.
Preview
@props([
'heading' => 'New arrivals',
'subheading' => 'Crafted essentials, restocked weekly. Free shipping on orders over $75.',
'resultsCount' => 24,
'sortLabel' => 'Featured',
'sortOptions' => null,
'products' => null,
'currency' => 'USD',
])
@php
$sortOptions ??= [
'Featured',
'Newest',
'Price: Low to High',
'Price: High to Low',
'Top rated',
];
$products ??= [
[
'name' => 'Aero Knit Runner',
'category' => 'Footwear',
'price' => '118',
'compareAt' => '148',
'rating' => 4.5,
'reviews' => 214,
'sale' => 'Save 20%',
'soldOut' => false,
],
[
'name' => 'Merino Travel Crew',
'category' => 'Knitwear',
'price' => '96',
'compareAt' => null,
'rating' => 5,
'reviews' => 88,
'sale' => null,
'soldOut' => false,
],
[
'name' => 'Cascade Weatherproof Shell',
'category' => 'Outerwear',
'price' => '214',
'compareAt' => '260',
'rating' => 4,
'reviews' => 132,
'sale' => 'Save $46',
'soldOut' => false,
],
[
'name' => 'Field Canvas Tote',
'category' => 'Accessories',
'price' => '72',
'compareAt' => null,
'rating' => 4.5,
'reviews' => 47,
'sale' => 'New',
'soldOut' => false,
],
[
'name' => 'Studio Linen Shirt',
'category' => 'Shirts',
'price' => '84',
'compareAt' => '110',
'rating' => 4,
'reviews' => 309,
'sale' => 'Save 24%',
'soldOut' => false,
],
[
'name' => 'Trail Insulated Bottle',
'category' => 'Gear',
'price' => '38',
'compareAt' => null,
'rating' => 5,
'reviews' => 521,
'sale' => null,
'soldOut' => false,
],
[
'name' => 'Everyday Tech Backpack',
'category' => 'Bags',
'price' => '149',
'compareAt' => '179',
'rating' => 4.5,
'reviews' => 176,
'sale' => 'Save $30',
'soldOut' => false,
],
[
'name' => 'Coast Wool Beanie',
'category' => 'Accessories',
'price' => '34',
'compareAt' => null,
'rating' => 4,
'reviews' => 64,
'sale' => null,
'soldOut' => true,
],
];
@endphp
<section {{ $attributes->merge(['class' => 'bg-background py-16 text-foreground sm:py-20']) }}>
<div class="mx-auto max-w-7xl px-4">
<header class="max-w-2xl">
<h2 class="text-balance text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
@if ($subheading)
<p class="mt-4 text-pretty text-base text-muted-foreground sm:text-lg">{{ __($subheading) }}</p>
@endif
</header>
{{-- Toolbar: results count + sort menu --}}
<div
x-data="{ open: false, sort: @js(__($sortLabel)) }"
class="mt-8 flex flex-col gap-4 border-b border-border pb-4 sm:flex-row sm:items-center sm:justify-between"
>
<p class="text-sm text-muted-foreground" aria-live="polite">
{{ __('Showing :count results', ['count' => $resultsCount]) }}
</p>
<div class="relative inline-flex shrink-0">
<x-ui.button
variant="outline"
size="sm"
type="button"
class="gap-2"
aria-haspopup="listbox"
x-bind:aria-expanded="open ? 'true' : 'false'"
x-on:click="open = !open"
>
<span class="text-muted-foreground">{{ __('Sort by') }}:</span>
<span class="font-medium text-foreground" x-text="sort"></span>
<svg
class="-me-2 size-4 text-muted-foreground transition-transform"
x-bind:class="open && '-rotate-180'"
viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"
>
<path d="m6 9 6 6 6-6" />
</svg>
</x-ui.button>
<div
x-show="open"
x-cloak
x-transition.opacity.duration.150ms
x-on:click.outside="open = false"
x-on:keydown.escape.window="open = false"
role="listbox"
aria-label="{{ __('Sort products') }}"
class="absolute end-0 top-full z-10 mt-2 w-56 overflow-hidden rounded-md border border-border bg-card py-2 text-card-foreground shadow-md"
>
@foreach ($sortOptions as $option)
<button
type="button"
role="option"
x-bind:aria-selected="sort === @js(__($option)) ? 'true' : 'false'"
x-on:click="sort = @js(__($option)); open = false"
class="flex w-full items-center justify-between gap-2 px-4 py-2 text-start text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none"
>
<span>{{ __($option) }}</span>
<svg
x-show="sort === @js(__($option))"
x-cloak
class="size-4 text-primary"
viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"
>
<path d="M20 6 9 17l-5-5" />
</svg>
</button>
@endforeach
</div>
</div>
</div>
{{-- Product grid --}}
<ul role="list" class="mt-8 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
@foreach ($products as $product)
<li>
<x-ui.product-card :product="$product" :currency="$currency" />
</li>
@endforeach
</ul>
</div>
</section>
Installation
php artisan ui:add blocks/product-listing-grid
Registry contract
Install confidence
php artisan ui:add blocks/product-listing-grid
writes only the generated targets below. The CLI validates each file hash before writing and
prompts before replacing local changes unless --force is used.
- Version
- 1.1.1
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/product-listing-grid.blade.php |
Registry dependencies
Package dependencies
composer: jml/brok:^0.2
Use with AI
A brief for your coding agent: what the block is, the install command, how to render it, its props and the rules. Copy it, or open a prompt about this block in an assistant.
# Brok UI block: Product Listing (`product-listing-grid`)
An ecommerce shop grid with a results count and sort dropdown toolbar above a responsive 2-to-4-column grid of product cards, each composed from the product-card primitive with a sale badge, wishlist heart, name, star rating with review count, price with optional compare-at, and an add-to-cart button.
Brok UI is a Laravel Blade registry. `ui:add` copies this block into the app as plain Blade the app owns; it composes installed `<brok:*>` primitives and semantic design tokens.
## Install
```bash
php artisan ui:add blocks/product-listing-grid
```
## Render it
```blade
<x-blocks.product-listing-grid />
```
## Props
- `heading` (string, default `New arrivals`) — Section heading.
- `subheading` (string, default `Crafted essentials, restocked weekly. Free shipping on orders over $75.`) — Supporting copy under the heading.
- `results-count` (int, default `24`) — Number of matching products shown in the toolbar.
- `sort-label` (string, default `Featured`) — Initial label for the sort dropdown.
- `sort-options` (mixed|null, default `null`) — Array of sort option label strings shown in the dropdown.
- `products` (mixed|null, default `null`) — Array of product entries rendered in the grid.
- `currency` (string, default `USD`) — ISO currency code used to format product prices.
## Use when
- Rendering an ecommerce shop grid with a results-count and an interactive sort dropdown above a responsive 2-to-4-column grid of product cards (sale badge, wishlist heart, rating, price, add-to-cart).
- Needing the sort control itself to be a working, keyboard-accessible listbox rather than a static button.
## Avoid when
- Needing a row/list layout instead of a card grid; use product-listing-list, or a horizontal snap-scroll carousel; use product-listing-carousel.
## Rules
- Render the installed block with `<x-blocks.product-listing-grid />` and pass data through its props; edit the copied file only for structural changes.
- Keep the semantic design tokens (`bg-background`, `text-muted-foreground`); never swap in raw colour utilities.
- Keep the `data-slot` attributes and the logical (start/end) spacing so the markup still mirrors under `dir="rtl"`.
## Links
- Docs: https://brokui.dev/blocks/product-listing-grid
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/product-listing-grid.json
Working in Claude Code, Cursor or Codex? Give the agent the whole registry through the MCP server or the Brok UI skill.
Guidance
Use when
- Rendering an ecommerce shop grid with a results-count and an interactive sort dropdown above a responsive 2-to-4-column grid of product cards (sale badge, wishlist heart, rating, price, add-to-cart).
- Needing the sort control itself to be a working, keyboard-accessible listbox rather than a static button.
Avoid when
- Needing a row/list layout instead of a card grid; use product-listing-list, or a horizontal snap-scroll carousel; use product-listing-carousel.
Anti-patterns
- Do not replace semantic props with conflicting utility classes.
- Do not remove labels, focus styles, or state attributes.
- Anatomy
Usage
Render the block as a component, passing data where useful:
<x-blocks.product-listing-grid />
Built from primitives
This block composes installed <brok:*> primitives and semantic design
tokens only — it does not reimplement any primitive. Re-theme it (light, dark, admin, customer) by
editing CSS variables; flip the preview to RTL to confirm it mirrors.
Source
The exact, editable file ui:add writes
into your app. The preview above renders this same source — there are no preview-only blocks.
@props([
'heading' => 'New arrivals',
'subheading' => 'Crafted essentials, restocked weekly. Free shipping on orders over $75.',
'resultsCount' => 24,
'sortLabel' => 'Featured',
'sortOptions' => null,
'products' => null,
'currency' => 'USD',
])
@php
$sortOptions ??= [
'Featured',
'Newest',
'Price: Low to High',
'Price: High to Low',
'Top rated',
];
$products ??= [
[
'name' => 'Aero Knit Runner',
'category' => 'Footwear',
'price' => '118',
'compareAt' => '148',
'rating' => 4.5,
'reviews' => 214,
'sale' => 'Save 20%',
'soldOut' => false,
],
[
'name' => 'Merino Travel Crew',
'category' => 'Knitwear',
'price' => '96',
'compareAt' => null,
'rating' => 5,
'reviews' => 88,
'sale' => null,
'soldOut' => false,
],
[
'name' => 'Cascade Weatherproof Shell',
'category' => 'Outerwear',
'price' => '214',
'compareAt' => '260',
'rating' => 4,
'reviews' => 132,
'sale' => 'Save $46',
'soldOut' => false,
],
[
'name' => 'Field Canvas Tote',
'category' => 'Accessories',
'price' => '72',
'compareAt' => null,
'rating' => 4.5,
'reviews' => 47,
'sale' => 'New',
'soldOut' => false,
],
[
'name' => 'Studio Linen Shirt',
'category' => 'Shirts',
'price' => '84',
'compareAt' => '110',
'rating' => 4,
'reviews' => 309,
'sale' => 'Save 24%',
'soldOut' => false,
],
[
'name' => 'Trail Insulated Bottle',
'category' => 'Gear',
'price' => '38',
'compareAt' => null,
'rating' => 5,
'reviews' => 521,
'sale' => null,
'soldOut' => false,
],
[
'name' => 'Everyday Tech Backpack',
'category' => 'Bags',
'price' => '149',
'compareAt' => '179',
'rating' => 4.5,
'reviews' => 176,
'sale' => 'Save $30',
'soldOut' => false,
],
[
'name' => 'Coast Wool Beanie',
'category' => 'Accessories',
'price' => '34',
'compareAt' => null,
'rating' => 4,
'reviews' => 64,
'sale' => null,
'soldOut' => true,
],
];
@endphp
<section {{ $attributes->merge(['class' => 'bg-background py-16 text-foreground sm:py-20']) }}>
<div class="mx-auto max-w-7xl px-4">
<header class="max-w-2xl">
<h2 class="text-balance text-3xl font-bold tracking-tight sm:text-4xl">{{ __($heading) }}</h2>
@if ($subheading)
<p class="mt-4 text-pretty text-base text-muted-foreground sm:text-lg">{{ __($subheading) }}</p>
@endif
</header>
{{-- Toolbar: results count + sort menu --}}
<div
x-data="{ open: false, sort: @js(__($sortLabel)) }"
class="mt-8 flex flex-col gap-4 border-b border-border pb-4 sm:flex-row sm:items-center sm:justify-between"
>
<p class="text-sm text-muted-foreground" aria-live="polite">
{{ __('Showing :count results', ['count' => $resultsCount]) }}
</p>
<div class="relative inline-flex shrink-0">
<x-ui.button
variant="outline"
size="sm"
type="button"
class="gap-2"
aria-haspopup="listbox"
x-bind:aria-expanded="open ? 'true' : 'false'"
x-on:click="open = !open"
>
<span class="text-muted-foreground">{{ __('Sort by') }}:</span>
<span class="font-medium text-foreground" x-text="sort"></span>
<svg
class="-me-2 size-4 text-muted-foreground transition-transform"
x-bind:class="open && '-rotate-180'"
viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"
>
<path d="m6 9 6 6 6-6" />
</svg>
</x-ui.button>
<div
x-show="open"
x-cloak
x-transition.opacity.duration.150ms
x-on:click.outside="open = false"
x-on:keydown.escape.window="open = false"
role="listbox"
aria-label="{{ __('Sort products') }}"
class="absolute end-0 top-full z-10 mt-2 w-56 overflow-hidden rounded-md border border-border bg-card py-2 text-card-foreground shadow-md"
>
@foreach ($sortOptions as $option)
<button
type="button"
role="option"
x-bind:aria-selected="sort === @js(__($option)) ? 'true' : 'false'"
x-on:click="sort = @js(__($option)); open = false"
class="flex w-full items-center justify-between gap-2 px-4 py-2 text-start text-sm text-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none"
>
<span>{{ __($option) }}</span>
<svg
x-show="sort === @js(__($option))"
x-cloak
class="size-4 text-primary"
viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"
>
<path d="M20 6 9 17l-5-5" />
</svg>
</button>
@endforeach
</div>
</div>
</div>
{{-- Product grid --}}
<ul role="list" class="mt-8 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
@foreach ($products as $product)
<li>
<x-ui.product-card :product="$product" :currency="$currency" />
</li>
@endforeach
</ul>
</div>
</section>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.1 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0