mantine-composite-filters
A powerful, flexible composite filters component for Mantine with support for multiple filter types, presets, history, and advanced customization
Installation
Peer Dependencies
This package requires the following peer dependencies:
Make sure you have Mantine properly set up in your project. See Mantine Getting Started for setup instructions.
Required setup:
MantineProviderwrapping your appNotificationscomponent for toast notifications- Import
mantine-composite-filters/styles.cssin your app
Overview
Build powerful filter interfaces in minutes. CompositeFiltersInput brings LinkedIn-style composite filtering to your Mantine apps - complete with type-safe definitions, smart operators, presets, and full keyboard support.
Why use this?
- Type any field name to start filtering
- Smart operator selection based on data type
- Save filter combinations as reusable presets
- Full keyboard navigation for power users
- Flexible storage with localStorage default or custom adapters
Quick Start
Three props to get started:
Interactive Playground
Options
Filter Types
Seven built-in types cover most filtering needs:
Limiting Filters
Control complexity with maxFilters:
Layout Options
Two overflow modes for different UI needs:
Scroll Mode (default)
Filters scroll horizontally when they exceed the container width
Wrap Mode
Filters wrap to multiple lines when they exceed the container width
Presets & History
Let users save and recall filter combinations:
Click the ⋮ menu to:
- Save current filters as a preset
- Load saved presets
- Mark presets as favorites
- View filter history
Data persists in browser localStorage
Built-in features (all persisted to localStorage by default):
- Save presets - Click "Save as preset" to open a modal where you can name and store filter combinations
- Favorites - Star presets for quick access
- History - Auto-tracked recent filter combinations (last 10)
Custom Save Preset Modal
You can provide your own modal for saving presets using the renderSavePresetModal prop:
The SavePresetModalProps includes:
opened- Whether the modal should be visibleonClose- Function to close the modalonSave- Function to call with the preset name when savingactiveFilters- Current active filters being saved
Custom Storage Adapters
Need to store presets on your server or use a different storage mechanism? Create custom storage adapters:
Data is lost on page refresh
Storage Adapter Interface:
interface StorageAdapter<T> {
get: () => T | Promise<T>;
set: (value: T) => void | Promise<void>;
remove: () => void | Promise<void>;
}StorageAdapter Interface
Built-in Adapters
The package exports createLocalStorageAdapter for creating localStorage adapters with proper Date serialization:
API Storage Example
Store presets on your server:
useCompositeFilters Hook
The useCompositeFilters hook provides a complete state management solution for filters, presets, and history - all in one hook with 70+ helper functions.
Basic Usage
Hook Options
Available Functions
Filter CRUD Operations:
Filter Getters:
Filter Checks:
Reordering:
Utilities:
Serialization:
Presets:
History:
Definitions:
State Tracking:
Examples
Programmatic Filter Management:
URL Sync:
API Integration:
Dirty State Tracking:
Using Individual Hooks
For more granular control, you can also use the individual hooks:
Styles API
CompositeFiltersInput supports Styles API, you can add styles to any inner element of the component with classNames prop.
Component Styles API
Hover over selectors to highlight corresponding elements
Styling Examples
Make it yours with styles or classNames:
Inline Styles
CSS Classes
Custom Pills
Replace default filter chips with your own creative designs:
Add some filters to preview different pill styles
Gradient Style
Outlined with Icon
Card Style with Color Accent
Keyboard Shortcuts
Power user? Navigate without touching your mouse:
In Action
See it work with real data filtering:
Showing 5 of 5 users
| User | Role | Department | Status |
|---|---|---|---|
AC Alice Chen alice@company.com | admin | Engineering | active |
BS Bob Smith bob@company.com | editor | Design | active |
CD Carol Davis carol@company.com | viewer | Marketing | inactive |
DW Dan Wilson dan@company.com | editor | Sales | active |
EM Eva Martinez eva@company.com | viewer | Engineering | active |
Pro Tips
Inline Editing - Click any part of an active filter to edit it directly (field, operator, or value).
Extend the Menu - Add your own actions:
Isolate Storage - Use storageKeyPrefix when you have multiple filter instances:
API Reference
FilterDefinition
ActiveFilter
TypeScript
Fully typed. Import what you need:
Tips
- Debounce - For large datasets, debounce the
onChangebefore fetching - Server validation - Always validate filter values server-side
- Mobile UX - Use
overflowMode="wrap"on smaller screens - Unique keys - Each filter definition needs a unique
key