Skip to main content
BlocksFiltersSidebar filter panel with product grid

shadcn/ui Filters block for Base UISidebar filter panel with product grid

Sidebar filter panel built with shadcn/ui Checkbox, ToggleGroup, RadioGroup, Input and Separator. Sections cover Category with counts, Size pills, colour swatch dots, a price range input with min/max fields and a Rating radio list, with a Clear all link at the top. It sits beside a Skeleton product grid so the layout reads as a real category page.

Free@shadcnpro/base/filters-01

Preview

Installation

npx shadcn@latest add @shadcnpro/base/filters-01

First time? Add the @shadcnpro registry to components.json as shown in Installation. Free blocks install without a license key.

Let your AI editor install it

The shadcn/ui Pro MCP server lets Cursor, Claude Code and VS Code find and install blocks like Sidebar filter panel with product grid from one prompt. It is included in every Pro plan.

Add the shadcn/ui components

Sidebar filter panel with product grid uses Checkbox, Input, Label, Radio Group, Separator, Skeleton and Toggle Group, from the Base UI components set up in your components.json.

npx shadcn@latest add checkbox input label radio-group separator skeleton toggle-group

Install the npm packages

npm install lucide-react

Copy the code

Paste it into components/blocks/filters-01.tsx.

components/blocks/filters-01.tsx
'use client';

import { CheckIcon, StarIcon } from 'lucide-react';
import { useState } from 'react';

import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
import { Separator } from '@/components/ui/separator';
import { Skeleton } from '@/components/ui/skeleton';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';

const categories = [
  { id: 'new', label: 'New in', count: 24 },
  { id: 'women', label: 'Women', count: 86 },
  { id: 'men', label: 'Men', count: 72 },
  { id: 'bags', label: 'Bags & Accessories', count: 41 },
  { id: 'home', label: 'Home', count: 58 },
  { id: 'tech', label: 'Tech', count: 19 },
];

const sizes = ['XS', 'S', 'M', 'L', 'XL'];

const colours = [
  { id: 'oat', label: 'Oat', hex: '#d9cbb3' },
  { id: 'charcoal', label: 'Charcoal', hex: '#3a3a3a' },
  { id: 'moss', label: 'Moss', hex: '#5d6b4a' },
  { id: 'sand', label: 'Sand', hex: '#c9b899' },
  { id: 'white', label: 'White', hex: '#f3f1ec' },
  { id: 'black', label: 'Black', hex: '#111111' },
  { id: 'navy', label: 'Navy', hex: '#273554' },
  { id: 'rust', label: 'Rust', hex: '#a2543a' },
];

const PRICE_MAX = 500;

/**
 * Sidebar filter panel: Category Checkboxes with counts, Size ToggleGroup pills, colour swatch dots, a price range input with min/max Inputs and a Rating RadioGroup, rendered next to a Skeleton product grid for context.
 */
export default function Filters01() {
  const [selectedCategories, setSelectedCategories] = useState<string[]>(['men']);
  const [selectedSizes, setSelectedSizes] = useState<string[]>(['M']);
  const [selectedColours, setSelectedColours] = useState<string[]>(['oat']);
  const [maxPrice, setMaxPrice] = useState(250);
  const [rating, setRating] = useState('4');

  const activeCount =
    selectedCategories.length +
    selectedSizes.length +
    selectedColours.length +
    (maxPrice < PRICE_MAX ? 1 : 0) +
    (rating ? 1 : 0);

  const clearAll = () => {
    setSelectedCategories([]);
    setSelectedSizes([]);
    setSelectedColours([]);
    setMaxPrice(PRICE_MAX);
    setRating('');
  };

  const toggleCategory = (id: string, checked: boolean) =>
    setSelectedCategories((prev) =>
      checked ? [...prev, id] : prev.filter((c) => c !== id)
    );
  const toggleColour = (id: string) =>
    setSelectedColours((prev) =>
      prev.includes(id) ? prev.filter((c) => c !== id) : [...prev, id]
    );

  return (
    <section className="w-full py-8 sm:py-12">
      <div className="mx-auto w-full max-w-6xl px-6">
        <div className="grid grid-cols-1 gap-8 md:grid-cols-4 md:gap-10">
          <aside className="w-full max-w-xs">
            <form className="flex flex-col gap-6" onSubmit={(e) => e.preventDefault()}>
              <div className="flex items-center justify-between">
                <h2 className="font-semibold text-foreground">
                  Filters{' '}
                  {activeCount > 0 ? (
                    <span className="font-normal text-muted-foreground">({activeCount})</span>
                  ) : null}
                </h2>
                <button
                  className="text-muted-foreground text-sm underline-offset-4 hover:text-foreground hover:underline"
                  onClick={clearAll}
                  type="button"
                >
                  Clear all
                </button>
              </div>

              <fieldset className="flex flex-col gap-3">
                <legend className="mb-3 font-medium text-foreground text-sm">Category</legend>
                {categories.map((category) => (
                  <div className="flex items-center gap-3" key={category.id}>
                    <Checkbox
                      checked={selectedCategories.includes(category.id)}
                      id={`filter-cat-${category.id}`}
                      name="category"
                      onCheckedChange={(checked) =>
                        toggleCategory(category.id, checked === true)
                      }
                      value={category.id}
                    />
                    <Label
                      className="flex flex-1 items-center justify-between font-normal"
                      htmlFor={`filter-cat-${category.id}`}
                    >
                      <span>{category.label}</span>
                      <span className="text-muted-foreground text-xs tabular-nums">
                        {category.count}
                      </span>
                    </Label>
                  </div>
                ))}
              </fieldset>

              <Separator />

              <div>
                <p className="font-medium text-foreground text-sm">Size</p>
                <ToggleGroup
                  aria-label="Size"
                  className="mt-3 flex-wrap justify-start"
                  multiple
                  onValueChange={setSelectedSizes}
                  spacing={1.5}
                  value={selectedSizes}
                  variant="outline"
                >
                  {sizes.map((size) => (
                    <ToggleGroupItem
                      className="min-w-9 rounded-md px-2 data-pressed:border-primary data-pressed:bg-primary data-pressed:text-primary-foreground"
                      key={size}
                      value={size}
                    >
                      {size}
                    </ToggleGroupItem>
                  ))}
                </ToggleGroup>
              </div>

              <Separator />

              <div>
                <p className="font-medium text-foreground text-sm">Colour</p>
                <div className="mt-3 flex flex-wrap gap-2">
                  {colours.map((colour) => {
                    const active = selectedColours.includes(colour.id);
                    return (
                      <button
                        aria-label={colour.label}
                        aria-pressed={active}
                        className={
                          active
                            ? 'flex size-8 items-center justify-center rounded-full border-2 border-primary ring-2 ring-background ring-offset-0'
                            : 'flex size-8 items-center justify-center rounded-full border border-border hover:border-foreground/40'
                        }
                        key={colour.id}
                        onClick={() => toggleColour(colour.id)}
                        title={colour.label}
                        type="button"
                      >
                        <span
                          className="flex size-6 items-center justify-center rounded-full"
                          style={{ backgroundColor: colour.hex }}
                        >
                          {active ? (
                            <CheckIcon
                              aria-hidden="true"
                              className="size-3.5 text-white mix-blend-difference"
                            />
                          ) : null}
                        </span>
                      </button>
                    );
                  })}
                </div>
              </div>

              <Separator />

              <div>
                <div className="flex items-center justify-between">
                  <Label className="font-medium" htmlFor="filter-price-range">
                    Price
                  </Label>
                  <span className="text-muted-foreground text-xs tabular-nums">
                    €0 – €{maxPrice}
                  </span>
                </div>
                <input
                  aria-label="Maximum price"
                  className="mt-3 w-full accent-primary"
                  id="filter-price-range"
                  max={PRICE_MAX}
                  min={0}
                  name="priceMax"
                  onChange={(e) => setMaxPrice(Number(e.target.value))}
                  step={10}
                  type="range"
                  value={maxPrice}
                />
                <div className="mt-3 grid grid-cols-2 gap-2">
                  <div className="grid gap-1">
                    <Label className="text-muted-foreground text-xs" htmlFor="filter-price-min">
                      Min
                    </Label>
                    <Input
                      autoComplete="off"
                      className="tabular-nums"
                      defaultValue={0}
                      id="filter-price-min"
                      inputMode="numeric"
                      name="priceMinInput"
                      type="number"
                    />
                  </div>
                  <div className="grid gap-1">
                    <Label className="text-muted-foreground text-xs" htmlFor="filter-price-max">
                      Max
                    </Label>
                    <Input
                      autoComplete="off"
                      className="tabular-nums"
                      id="filter-price-max"
                      inputMode="numeric"
                      name="priceMaxInput"
                      onChange={(e) =>
                        setMaxPrice(Math.min(PRICE_MAX, Math.max(0, Number(e.target.value) || 0)))
                      }
                      type="number"
                      value={maxPrice}
                    />
                  </div>
                </div>
              </div>

              <Separator />

              <div>
                <p className="font-medium text-foreground text-sm">Rating</p>
                <RadioGroup
                  className="mt-3 gap-2.5"
                  name="rating"
                  onValueChange={setRating}
                  value={rating}
                >
                  {[4, 3, 2].map((stars) => (
                    <div className="flex items-center gap-3" key={stars}>
                      <RadioGroupItem
                        aria-label={`${stars} stars and up`}
                        id={`filter-rating-${stars}`}
                        value={String(stars)}
                      />
                      <Label
                        className="flex items-center gap-1.5 font-normal"
                        htmlFor={`filter-rating-${stars}`}
                      >
                        <span className="flex items-center">
                          {Array.from({ length: 5 }).map((_, i) => (
                            <StarIcon
                              aria-hidden="true"
                              className={
                                i < stars
                                  ? 'size-3.5 fill-current text-foreground'
                                  : 'size-3.5 text-muted-foreground/40'
                              }
                              key={i}
                            />
                          ))}
                        </span>
                        <span className="text-muted-foreground text-xs">&amp; up</span>
                      </Label>
                    </div>
                  ))}
                </RadioGroup>
              </div>
            </form>
          </aside>

          <div className="md:col-span-3">
            <div className="flex items-center justify-between">
              <Skeleton className="h-5 w-32 bg-muted-foreground/15" />
              <Skeleton className="h-9 w-40 rounded-md bg-muted-foreground/15" />
            </div>
            <div className="mt-6 grid grid-cols-2 gap-6 sm:grid-cols-3">
              {Array.from({ length: 6 }).map((_, i) => (
                <div className="flex flex-col gap-3" key={i}>
                  <Skeleton className="aspect-[3/4] w-full rounded-lg bg-muted-foreground/15" />
                  <Skeleton className="h-4 w-3/4 bg-muted-foreground/15" />
                  <Skeleton className="h-4 w-1/3 bg-muted-foreground/15" />
                </div>
              ))}
            </div>
          </div>
        </div>
      </div>
    </section>
  );
}

Use it

Import it where you need it and update the import path to match your project.

Usage
import Filters01 from '@/components/blocks/filters-01';

export default function Page() {
  return <Filters01 />;
}

Overview

Sidebar filter panel with product grid is a free filters block for shadcn/ui and Base UI. It is built from the Checkbox, Input, Label, Radio Group, Separator, Skeleton and Toggle Group components with lucide-react, and installs as a single file you own and can edit.

It only uses semantic tokens such as bg-background, text-muted-foreground and border-border, so it follows your theme, radius and fonts and switches with dark mode. It is responsive from desktop to mobile; the width controls above the preview show each size. The same layout is in the shadcn/ui Pro Figma kit, so design and code start from one source.

Category
Filters
Component library
Base UI (@base-ui/react)
Also available for
Radix UI, React Aria
npm packages
lucide-react
Files
components/blocks/filters-01.tsx
Access
Free, installs without a license key

Frequently asked questions

Pricing, installation and Base UI details for Sidebar filter panel with product grid.