Filter Panel
Forms
Block
Data Display
A comprehensive filter component with sidebar, horizontal, and dropdown variants. Supports checkboxes, ranges, and search filters with collapsible sections.
Sidebar Variant
Vertical filter panel for side navigation
Active filters:
{}Horizontal Variant
Filter bar above content with dropdown filters
Content area with active filters:
{}Dropdown Variant
Compact dropdown menu with collapsible filter sections (like Tasks template)
← Click to expand
Active filters:
{}With Apply Button
Deferred filter application
Usage
How to implement the Filter Panel
import { FilterPanel, type FilterGroup, type FilterState } from '@/blocks/forms/filter-panel'
// Define filter groupsconst filters: FilterGroup[] = [ { type: 'search', id: 'search', label: 'Search', placeholder: 'Search...', }, { type: 'checkbox', id: 'category', label: 'Category', options: [ { id: 'electronics', label: 'Electronics', count: 42 }, { id: 'clothing', label: 'Clothing', count: 156 }, ], }, { type: 'range', id: 'price', label: 'Price', min: 0, max: 1000, unit: '$', },]
// Sidebar variantconst [filterState, setFilterState] = useState<FilterState>({})
<FilterPanel variant="sidebar" groups={filters} value={filterState} onChange={setFilterState}/>
// Horizontal variant (above data table)<FilterPanel variant="horizontal" groups={filters} value={filterState} onChange={setFilterState}/>
// Dropdown variant (compact, single button)<FilterPanel variant="dropdown" groups={filtersWithIcons} value={filterState} onChange={setFilterState} buttonSize="md" buttonVariant="secondary"/>
// With deferred apply<FilterPanel variant="sidebar" groups={filters} showApplyButton onApply={(filters) => fetchData(filters)}/>Built With
11 componentsThis block uses the following UI components from the design system:
Filter Group Types
Available filter types
// Checkbox filter group{ type: 'checkbox', id: 'category', label: 'Category', defaultExpanded: true, options: [ { id: 'option1', label: 'Option 1', count: 42 }, { id: 'option2', label: 'Option 2', count: 18 }, ],}
// Range filter group{ type: 'range', id: 'price', label: 'Price Range', min: 0, max: 1000, step: 10, unit: '$', defaultValue: [0, 500],}
// Search filter group{ type: 'search', id: 'search', label: 'Search', placeholder: 'Search products...',}
// Filter group with icon (for dropdown variant)import { Flag } from 'lucide-react'
{ type: 'checkbox', id: 'priority', label: 'Priority', icon: Flag, // Shows in dropdown trigger row options: [ { id: 'high', label: 'High' }, { id: 'medium', label: 'Medium' }, ],}Props
FilterPanel component props
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "sidebar" | "horizontal" | "dropdown" | "sidebar" | Layout variant |
groups* | FilterGroup[] | — | Filter configuration |
value | FilterState | — | Current filter values |
onChange | (filters: FilterState) => void | — | Filter change callback |
title | string | "Filters" | Panel title / button label |
showClearAll | boolean | true | Show clear all button |
showApplyButton | boolean | false | Defer filter application (sidebar only) |
onApply | (filters: FilterState) => void | — | Apply button callback |
width | string | "w-64" | Sidebar width class |
collapsible | boolean | true | Enable collapsible sections |
buttonSize | "sm" | "md" | "lg" | "md" | Dropdown trigger button size |
buttonVariant | "primary" | "secondary" | "outline" | "ghost" | "secondary" | Dropdown trigger button variant |
Features
Filter Panel capabilities
- Multiple filter types: Checkbox, range slider, and search filters
- Three layout variants: Sidebar, horizontal, and compact dropdown
- Collapsible sections: Expandable/collapsible filter groups
- Active filter badges: Visual indicators for applied filters
- Clear individual/all: Remove single filters or clear all
- Item counts: Show result counts per filter option
- Search within filters: Search long option lists
- Mobile responsive: Sheet-based filters on mobile
- Custom icons: Per-group icons for dropdown variant
- Deferred apply: Optional apply button for batch updates
- Dark mode: Full dark mode support