1. Overview
This single-file HTML application demonstrates a modern product listing interface with advanced client-side filtering. It features a price range slider, multi-select product categories, availability filters, and multiple sorting options. The interface is fully responsive and includes a mobile-friendly modal filter system.
This UI component solves technical debt by encapsulating dual-thumb range selection logic into a self-contained unit that leverages Bootstrap 5's native input[type=range] with custom JavaScript overlays. It functions as a modular unit by separating concerns: HTML for structure, CSS for visual feedback, and JavaScript for real-time value synchronization. Dependencies are minimal, relying primarily on Bootstrap 5 core and vanilla JS, leading to performance gains through reduced DOM queries and efficient event handling that avoids layout thrashing in legacy systems.
2. Architecture
The application is built as a self-contained HTML document using:
- HTML5 for structure
- Bootstrap 5.3 for responsive grid and components
- Vanilla JavaScript (ES6+) for all interactivity
- CSS3 with custom styling and Google Fonts
Important
- Container div with relative positioning for overlay management
- Dual range inputs absolutely positioned for independent thumb control
- Progress bar div that dynamically updates width based on min-max values
- Tooltip elements synced to current values using JS calculations
- ARIA attributes for accessibility compliance
- Custom CSS variables for theming flexibility
3. Data Structure
Product data is stored in a JavaScript array of objects:
const products = [
{
id: 1,
name: "NovaFlow",
type: "saas",
price: 89,
availability: "active",
img: "https://picsum.photos/..."
},
// ... more products
];
4. Main Components
4.1 Sidebar Filters (Desktop)
The left sidebar contains three main filter groups:
- Maximum Price: Range slider (10–800) with live value display
- Product Type: Multi-select checkboxes (SaaS, API, DevTools)
- Availability: Radio buttons (All, Active Subscription, Free Trial)
4.2 Products Grid
A responsive Bootstrap grid (row-cols-1 row-cols-sm-2 row-cols-md-4) that renders product cards with:
- High-quality images (object-fit: cover)
- Product name and price
- Hover animations (lift + shadow)
4.3 Sorting Controls
Three sorting options using custom radio buttons with icons:
- Relevance (default)
- Price: Low to High
- Price: High to Low
5. Core JavaScript Functions
5.1 filterAndSortProducts()
The main filtering engine. It:
- Reads current filter states from the DOM
- Applies price, type, and availability filters
- Sorts results according to user selection
- Calls
renderProducts()
5.2 renderProducts(filtered)
Dynamically generates product cards using template literals and updates the results counter.
5.3 Event Handling
- Live filtering on any input change (
filterForm.addEventListener('change')) - Real-time price slider updates
- Sorting radio button listeners
- Clear filters functionality
6. Mobile Experience
The interface includes a dedicated mobile modal triggered by a "Filters" button (visible only on d-md-none). When the user applies filters in the modal, values are synchronized back to the main form before re-rendering.
7. Key Features
Real-time Updates
All filters update the product grid instantly without page reload.
Responsive Design
Optimized for desktop, tablet, and mobile with Bootstrap breakpoints.
Clean State Management
Form reset and value synchronization between desktop and mobile views.
Smooth UX
CSS transitions, hover effects, and intuitive controls.
8. Extensibility
This codebase can be easily extended by:
- Adding more filter categories (brands, ratings, etc.)
- Connecting to a real backend API instead of the static array
- Implementing pagination for larger datasets
- Adding localStorage persistence for user preferences
- Enhancing accessibility with ARIA labels
Technical documentation generated for the product filtering interface.
Built with vanilla JavaScript and Bootstrap 5.
Code Explanation and Integration Patterns
The JavaScript core handles value constraints to prevent min exceeding max through simple conditional swaps. This pattern eliminates the need for complex validation libraries in older systems. The HTML structure uses semantic elements that integrate directly into forms, reducing the architectural overhead of maintaining separate widget files.
<div class="range-slider">
<input type="range" id="minPrice" min="0" max="1000" value="100">
<input type="range" id="maxPrice" min="0" max="1000" value="800">
<div class="progress-container">
<div class="progress-bar"></div>
</div>
</div>
Performance Optimizations Achieved
By avoiding heavy frameworks and sticking to native events, this component cuts down on bundle size and improves load times significantly in enterprise applications. Throttling mechanisms ensure that rapid thumb movements don't overwhelm the main thread, a common issue in unoptimized legacy sliders that caused jank on mid-range devices.
Before vs After Implementation
Before adopting this component, legacy systems often suffered from bloated jQuery-based sliders with duplicated event handlers across pages, causing memory leaks and inconsistent layouts during responsive reflows. Custom CSS hacks for thumb styling led to cross-browser issues and increased maintenance debt. After integration, the modular approach centralizes logic, eliminating redundant code and providing consistent behavior across the application. This resolves specific problems like overlapping thumbs in price filters and poor mobile touch support that plagued older implementations.
Long-term Architectural Value
Adopting components like this fosters a more maintainable codebase where UI elements evolve independently from business logic, reducing overall technical debt accumulation over years of development. The clear separation of concerns encourages team collaboration and accelerates feature delivery in modern web applications. By investing in such reusable patterns, engineering teams build systems that remain adaptable as requirements change, ultimately delivering higher quality user experiences with lower long-term costs.