Skip to content

Product catalog filters in HTML and CSS

A faceted filter panel for a catalog: category, price, size, colour and stock, with a result counter, active filter chips, sorting and a mobile drawer.

Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Filtres de catalogue produits</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <div class="pcf" data-pcf>
        <div class="pcf__head" data-pcf-outside>
script.js
const PCF_X = '<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true" focusable="false"><path d="M5 5l10 10M15 5L5 15" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" /></svg>';

document.querySelectorAll("[data-pcf]").forEach((root) => {
  const form = root.querySelector("[data-pcf-form]");
  const panel = root.querySelector("[data-pcf-panel]");
  const toggle = root.querySelector("[data-pcf-toggle]");
  const badge = root.querySelector("[data-pcf-badge]");
  const backdrop = root.querySelector("[data-pcf-backdrop]");
  const list = root.querySelector("[data-pcf-list]");
  const items = [...list.children];
  const status = root.querySelector("[data-pcf-status]");
  const chips = root.querySelector("[data-pcf-chips]");
style.css
:root {
  --pcf-card: #ffffff;
  --pcf-text: #1f2421;
  --pcf-muted: #59615b;
  --pcf-line: #e2e5df;
  --pcf-line-strong: #7d867f;
  --pcf-field: #ffffff;
  --pcf-hover: #f4f5f1;
  --pcf-accent: #3d5a3f;
  --pcf-accent-hover: #2f4731;
  --pcf-accent-soft: #eef3ec;
  --pcf-accent-soft-hover: #dde8da;

Free component: copy it freely, including for commercial projects.

E-commerce components in HTML and CSS
  • A limited-time offer bar: countdown to a fixed date, one-click copyable promo code and a fallback message once the offer is over.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A sales card showing the discount that grows with the cart amount (-10% from €50, -15% from €100…) with a progress bar towards the next tier.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A Christmas gift guide filtered by budget and theme, with the number of ideas announced and an empty state offering to show everything again.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • The last order dates for delivery before Christmas, per shipping method, with the days left worked out from the visitor’s date.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A cart that shows live how much is left to add for free shipping, with a progress bar and recalculated totals.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A colour and size picker for a product page: the visual, price and stock follow the choice, and sold-out sizes are disabled.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component