Home / Blocks / E-commerce / Category Filters
5 blocks in this section

Shadcn Product Filter Components

Narrow a product list with shadcn/ui filter toolbars, expandable sidebars, sliders, checkboxes, and toggle-based controls.

How it works

Three steps to working code

Install a block and the files land in your repository. Nothing calls back to us.

  1. terminal

    $ npx shadcn@latest add @shadcnstore/category-filter-1

    ✓ Checking registry

    ✓ Installing dependencies

    01

    Run one command

    Every preview above prints its own. The CLI writes the block and the components it needs into your project.

    Installation docs
  2. your project 3 files added

    components/

    ├─ ui/

    ├─ button.tsx

    └─ navigation-menu.tsx

    └─ category-filter-1.tsx

    02

    Get real files

    React, TypeScript and Tailwind v4, with no framework imports. Next.js, Vite, Remix and Astro all work.

  3. category-filter-1.tsx

    <Menu.Trigger

    - asChild

    + render={<button />}

    />

    03

    Edit it as your own

    Built on Base UI, not Radix, so keyboard and focus behaviour come from the primitive.

Blocks that hold state already carry the use client directive the Next.js App Router needs.

Guide

Product filters, and the counting most of them get wrong#

A filter sidebar is easy to draw and hard to make correct. The layout takes an hour; the arithmetic behind the option counts takes considerably longer, and getting it wrong is why so many shops show a facet with twelve results that returns none. These five cover the layouts and the counting.

The five filter blocks#

  • Category Filter 1: a horizontal bar with dropdowns and an active-filter display. Free, and the right choice when there are only three or four things worth filtering by.
  • Category Filter 2: a sidebar with expandable categories and subcategories, for a catalogue with real depth.
  • Category Filter 3: a fuller sidebar with toggle-based selection and results that update as choices change.
  • Category Filter 4: the mobile-first drawer, with a live result count that settles as you choose and applied-filter chips that stay visible after it closes.
  • Category Filter 5: faceted search with correct exclude-own-facet counting, options that disable in place at zero, and a computed no-results suggestion.

Filter bar or filter sidebar#

A horizontal bar keeps the products higher on the page and reads better when the facet set is small. A sidebar carries more facets and lets somebody see the whole filter vocabulary at once, which matters when the catalogue is deep enough that people do not know what they can filter by.

The usual mistake is choosing the sidebar for a shop with four facets, which leaves a column of white space beside the grid, or choosing the bar for a shop with fifteen, which buries most of them behind a dropdown nobody opens.

Exclude-own-facet counting#

When somebody has selected Blue under colour, the counts shown next to the other colours must be computed as if no colour were selected, while still respecting every other active filter. Count colours against the fully filtered set instead and every unselected colour reads zero, which is technically true and completely useless.

Category Filter 5 implements that correctly. Options that genuinely reach zero disable in place rather than disappearing, so the list does not reflow under the pointer mid-click, and the vocabulary stays visible so somebody can see what they have ruled out.

Filters on a phone#

Category Filter 4 is a drawer, and the detail that makes it work is the result count updating as choices change. Somebody applying four filters blind and finding two products has wasted four taps; seeing the count settle at two before applying is what lets them back off one. Applied filters then stay visible as chips after the drawer closes, which is the part most mobile filter implementations drop.

When a filter combination returns nothing#

The empty result is a designed state, not an accident. Category Filter 5 computes a recoverable suggestion that names the filter to relax rather than printing a bare no-results message, which turns a dead end into one click back to a populated list. Every active filter stays visible so somebody can see exactly what they asked for.

Filters over any grid#

These work over a product grid most obviously, but nothing in them assumes a product. The same bars and sidebars filter a listing grid of properties, jobs or courses without modification. Upstream, product categories handle the coarse split that filters should not have to, and a storefront hero sets the context above both.

FAQ

Category Filters questions, answered

What people ask before choosing a block from this collection.

A sidebar carries more facets and suits a deep catalogue, which is what Category Filter 2 and 3 are for. A horizontal bar keeps the products higher on the page and works better when there are only three or four things worth filtering by.
Category Filter 4 is a drawer with a result count that updates and settles as choices change, so a shopper knows what they will get before applying. Applied filters stay visible as chips after the drawer closes, which is the part most mobile filter implementations drop.
Category Filter 5 implements exclude-own-facet counting, meaning a facet does not count itself when computing its own options, which is the arithmetic almost every hand-built faceted search gets wrong. Options that reach zero disable in place rather than disappearing, so the list does not jump under the pointer.
Category Filter 5 computes a recoverable suggestion, naming the filter to relax rather than showing a bare no results message. That turns a dead end into one click back to a populated list.
Category Filter 1, the horizontal bar with dropdowns and active filter display, is free. The sidebar, drawer and faceted search variants are Pro under the pricing licence.

Documentation

The components behind these blocks

How to install, customise and combine the shadcn/ui components this collection is built from.

Free & Premium Templates

Launch Faster with Complete Templates

Love these blocks? Get our free dashboard and landing page templates with 30+ pre-built pages and all the components you need. Premium templates with advanced features launching soon at $69.

Free Templates Now
30+ Pages Included
Premium Coming Soon