Product Filters
Storefront filter toolbars — a horizontal bar of filter dropdowns, a view toggle, sort control and active-filter chips.
Preview
@props([
'resultCount' => 248,
'filterGroups' => null,
'activeSort' => 'Featured',
'activeChips' => null,
'activeView' => 'grid',
'clearHref' => '#',
])
@php
$filterGroups ??= ['Category', 'Size', 'Colour', 'Price'];
$activeChips ??= [
['label' => 'Category', 'value' => 'Trainers', 'href' => '#'],
['label' => 'Size', 'value' => '10', 'href' => '#'],
['label' => 'Price', 'value' => 'Under $120', 'href' => '#'],
];
// <x-ui.active-filters> reads label/value/href entries; a plain string chip
// (the pre-1.1 shape) still renders as a removable value-only chip.
$activeFilters = collect($activeChips)->map(fn ($chip) => is_array($chip)
? ['label' => __($chip['label'] ?? ''), 'value' => __($chip['value'] ?? ''), 'href' => $chip['href'] ?? '#']
: ['value' => __($chip), 'href' => '#'])->values()->all();
@endphp
<x-ui.section data-slot="product-filters" space="none" class="border-y border-border" {{ $attributes }}>
<div class="mx-auto max-w-7xl px-4 py-4">
<div class="flex flex-wrap items-center gap-4">
<p class="me-2 shrink-0 text-sm text-muted-foreground"><span class="font-semibold text-foreground">{{ number_format($resultCount) }}</span> {{ __('products') }}</p>
<div class="flex flex-wrap items-center gap-2" role="group" aria-label="{{ __('Filter options') }}">
@foreach ($filterGroups as $group)
<x-ui.button variant="outline" size="sm" type="button" class="gap-2">
{{ __($group) }}
<svg class="size-4 shrink-0 text-muted-foreground" 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>
@endforeach
</div>
<span class="flex-1" aria-hidden="true"></span>
<x-ui.segmented-nav as="div" :label="__('View layout')">
<x-ui.segmented-nav.item :active="$activeView === 'grid'" :aria-label="__('Grid view')">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1" /><rect x="14" y="3" width="7" height="7" rx="1" /><rect x="3" y="14" width="7" height="7" rx="1" /><rect x="14" y="14" width="7" height="7" rx="1" /></svg>
</x-ui.segmented-nav.item>
<x-ui.segmented-nav.item :active="$activeView === 'list'" :aria-label="__('List view')">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="18" x2="21" y2="18" /></svg>
</x-ui.segmented-nav.item>
</x-ui.segmented-nav>
{{-- A plain outline button: no listbox is composed here, so it carries no popup semantics. --}}
<x-ui.button variant="outline" size="sm" type="button" class="gap-2">
<span class="text-muted-foreground">{{ __('Sort by:') }}</span>
<span class="font-medium text-foreground">{{ __($activeSort) }}</span>
<svg class="size-4 shrink-0 text-muted-foreground" 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>
@if (! empty($activeFilters))
<x-ui.active-filters :filters="$activeFilters" :clear-href="$clearHref" class="mt-2" />
@endif
</div>
</x-ui.section>
Installation
php artisan ui:add blocks/product-filters-toolbar
Registry contract
Install confidence
php artisan ui:add blocks/product-filters-toolbar
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.2
- License
- open
- Stability
- stable
- Contract
- v1
- Foundation
- ≥ 1.0.0
| Type | Generated target |
|---|---|
| blade | resources/views/blocks/product-filters-toolbar.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 Filters (`product-filters-toolbar`)
A horizontal product-filter toolbar with result count, filter dropdown buttons, a grid/list view toggle, a sort control and removable active-filter chips.
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-filters-toolbar
```
## Render it
```blade
<x-blocks.product-filters-toolbar />
```
## Props
- `result-count` (int, default `248`) — Number of matching products shown at the start of the toolbar.
- `filter-groups` (mixed|null, default `null`) — Array of filter group labels rendered as dropdown-style buttons.
- `active-sort` (string, default `Featured`) — Label for the currently applied sort order.
- `active-chips` (mixed|null, default `null`) — Array of removable active-filter chip entries ({label, value, href}).
- `active-view` (string, default `grid`) — Which view toggle option (grid or list) is marked active.
- `clear-href` (string, default `#`) — Destination for clearing all active filters.
## Use when
- Placing a horizontal product-filter toolbar above a listing: a result count, filter dropdown buttons, a sort control and a grid/list view toggle.
- Showing removable active-filter chips beneath the toolbar so applied filters stay visible without opening a panel.
## Avoid when
- Needing a vertical sidebar of collapsible, checkbox-driven filter groups; use product-filters-sidebar instead.
## Rules
- Render the installed block with `<x-blocks.product-filters-toolbar />` 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-filters-toolbar
- Registry JSON (files, props, contract): https://brokui.dev/r/open/blocks/product-filters-toolbar.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
- Placing a horizontal product-filter toolbar above a listing: a result count, filter dropdown buttons, a sort control and a grid/list view toggle.
- Showing removable active-filter chips beneath the toolbar so applied filters stay visible without opening a panel.
Avoid when
- Needing a vertical sidebar of collapsible, checkbox-driven filter groups; use product-filters-sidebar instead.
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-filters-toolbar />
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([
'resultCount' => 248,
'filterGroups' => null,
'activeSort' => 'Featured',
'activeChips' => null,
'activeView' => 'grid',
'clearHref' => '#',
])
@php
$filterGroups ??= ['Category', 'Size', 'Colour', 'Price'];
$activeChips ??= [
['label' => 'Category', 'value' => 'Trainers', 'href' => '#'],
['label' => 'Size', 'value' => '10', 'href' => '#'],
['label' => 'Price', 'value' => 'Under $120', 'href' => '#'],
];
// <x-ui.active-filters> reads label/value/href entries; a plain string chip
// (the pre-1.1 shape) still renders as a removable value-only chip.
$activeFilters = collect($activeChips)->map(fn ($chip) => is_array($chip)
? ['label' => __($chip['label'] ?? ''), 'value' => __($chip['value'] ?? ''), 'href' => $chip['href'] ?? '#']
: ['value' => __($chip), 'href' => '#'])->values()->all();
@endphp
<x-ui.section data-slot="product-filters" space="none" class="border-y border-border" {{ $attributes }}>
<div class="mx-auto max-w-7xl px-4 py-4">
<div class="flex flex-wrap items-center gap-4">
<p class="me-2 shrink-0 text-sm text-muted-foreground"><span class="font-semibold text-foreground">{{ number_format($resultCount) }}</span> {{ __('products') }}</p>
<div class="flex flex-wrap items-center gap-2" role="group" aria-label="{{ __('Filter options') }}">
@foreach ($filterGroups as $group)
<x-ui.button variant="outline" size="sm" type="button" class="gap-2">
{{ __($group) }}
<svg class="size-4 shrink-0 text-muted-foreground" 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>
@endforeach
</div>
<span class="flex-1" aria-hidden="true"></span>
<x-ui.segmented-nav as="div" :label="__('View layout')">
<x-ui.segmented-nav.item :active="$activeView === 'grid'" :aria-label="__('Grid view')">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="3" y="3" width="7" height="7" rx="1" /><rect x="14" y="3" width="7" height="7" rx="1" /><rect x="3" y="14" width="7" height="7" rx="1" /><rect x="14" y="14" width="7" height="7" rx="1" /></svg>
</x-ui.segmented-nav.item>
<x-ui.segmented-nav.item :active="$activeView === 'list'" :aria-label="__('List view')">
<svg class="size-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="18" x2="21" y2="18" /></svg>
</x-ui.segmented-nav.item>
</x-ui.segmented-nav>
{{-- A plain outline button: no listbox is composed here, so it carries no popup semantics. --}}
<x-ui.button variant="outline" size="sm" type="button" class="gap-2">
<span class="text-muted-foreground">{{ __('Sort by:') }}</span>
<span class="font-medium text-foreground">{{ __($activeSort) }}</span>
<svg class="size-4 shrink-0 text-muted-foreground" 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>
@if (! empty($activeFilters))
<x-ui.active-filters :filters="$activeFilters" :clear-href="$clearHref" class="mt-2" />
@endif
</div>
</x-ui.section>
Ownership & lifecycle
Owner, release state, review evidence and adoption for this item.
- Owner
- Platform UI (@JoshJML)
- Current version
-
1.1.2 - Status
- Stable
- License
-
open - Deprecation
- Not deprecated
- Contract
-
v1 - Foundation
-
≥ 1.0.0