webdevpuneet.com

Bootstrap Advanced Search Panel — Free HTML CSS JS Snippet

Bootstrap Advanced Search Panel · Forms · Plain HTML, CSS & JS · Live preview

CategoryForms

Copy & paste

Source Code

<div class="container py-5 d-flex justify-content-center">
  <div class="card bsadv-card">
    <div class="card-body p-3">
      <div class="d-flex justify-content-between align-items-center">
        <input type="text" class="form-control me-2" id="bsadvKeyword" placeholder="Search tickets...">
        <button type="button" class="btn btn-outline-secondary flex-shrink-0" type="button" data-bs-toggle="collapse" data-bs-target="#bsadvPanel">
          Filters <span id="bsadvBadge" class="badge text-bg-secondary ms-1 d-none">0</span>
        </button>
      </div>

      <div class="collapse mt-3" id="bsadvPanel">
        <div class="row g-2">
          <div class="col-6">
            <label class="form-label small fw-semibold mb-1">Status</label>
            <select class="form-select form-select-sm" id="bsadvStatus">
              <option value="">Any</option>
              <option value="open">Open</option>
              <option value="pending">Pending</option>
              <option value="closed">Closed</option>
            </select>
          </div>
          <div class="col-6">
            <label class="form-label small fw-semibold mb-1">Priority</label>
            <select class="form-select form-select-sm" id="bsadvPriority">
              <option value="">Any</option>
              <option value="high">High</option>
              <option value="medium">Medium</option>
              <option value="low">Low</option>
            </select>
          </div>
          <div class="col-6">
            <label class="form-label small fw-semibold mb-1">From date</label>
            <input type="date" class="form-control form-control-sm" id="bsadvFrom">
          </div>
          <div class="col-6">
            <label class="form-label small fw-semibold mb-1">To date</label>
            <input type="date" class="form-control form-control-sm" id="bsadvTo">
          </div>
        </div>
        <div class="d-flex gap-2 mt-3">
          <button type="button" class="btn btn-dark btn-sm fw-bold" id="bsadvApply">Apply filters</button>
          <button type="button" class="btn btn-outline-secondary btn-sm" id="bsadvReset">Reset</button>
        </div>
      </div>

      <p class="small text-muted mt-3 mb-0" id="bsadvSummary">No filters applied.</p>
    </div>
  </div>
</div>

Extend with AI

Take This Snippet Further With AI

The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.

· Become a supporter

What's included

Features

Uses Bootstrap's real collapse component, not a custom-built expand/collapse
A live badge counts only the structured filter fields that are actually set
A generated plain-English summary sentence instead of a raw list of field values
Pressing Enter in the keyword field applies filters without needing to click the button
Reset clears every field and immediately re-syncs the badge and summary in one action

About this UI Snippet

Bootstrap Advanced Search Panel — HTML, CSS & JavaScript

Screenshot of the Bootstrap Advanced Search Panel snippet rendered live

The panel uses Bootstrap's real collapse component (data-bs-toggle="collapse") rather than a custom show/hide implementation, so it inherits Bootstrap's built-in animation and ARIA wiring for free. The filter count badge on the "Filters" toggle button is what lets a user know criteria are active even with the panel collapsed — fieldCount() counts only the structured dropdown and date fields (not the free-text keyword, which gets its own place in the summary sentence), since those are the filters a badge count meaningfully represents.

The summary line at the bottom is built by activeCriteria() into one readable sentence rather than a raw dump of field values, so "Searching for status: open, priority: high" reads the way a person would actually describe their own search back to themselves — a small but real usability difference from just listing form field names and values.

Step by step

How to Use

  1. 1
    Load the snippetThe panel is collapsed, the badge is hidden, and the summary reads "No filters applied."
  2. 2
    Click "Filters"The panel expands with Bootstrap's real collapse animation, revealing status, priority, and date fields.
  3. 3
    Select a status and a priorityClick "Apply filters" — the badge shows "2" and the summary describes both selections in plain English.
  4. 4
    Type a keyword and press EnterThe summary updates to include the keyword alongside the existing filters.
  5. 5
    Click "Reset"Every field clears, the badge disappears, and the summary reverts to "No filters applied."

Real-world uses

Common Use Cases

Support ticket and issue-tracking dashboards
Pairs with bootstrap-sortable-data-table to actually filter the rows a search like this describes.
SEARCH
Any list view needing more than a single search box
Combine with bootstrap-filter-chips to also show each applied criterion as its own removable chip.
CART
Ecommerce and marketplace search
Swap status/priority for category/price range for a product-search variant of the same panel.

Got questions?

Frequently Asked Questions

The badge is meant to summarize structured, discrete filter selections (dropdowns and dates); a free-text keyword already has its own visible place in the input box and the summary sentence, so counting it in the badge too would be redundant.

Yes. Keep each field in component state, derive fieldCount and the summary sentence from that state on every render, and use Bootstrap's collapse via a ref-driven Collapse instance or an equivalent framework transition.

Call your filtering function with the same field values read inside applyFilters(), right alongside (or instead of) updating the badge and summary — the criteria-gathering logic is already centralized in one place.

Design your website