The <ClearRefinements> component displays a button that clears all active refinements.
Import
import { ClearRefinements } from 'react-instantsearch';
Props
Attributes to include when clearing refinements. By default, all refineable attributes are included.<ClearRefinements includedAttributes={['brand', 'category']} />
Attributes to exclude from being cleared.<ClearRefinements excludedAttributes={['query']} />
Transform the refinement items before clearing them.<ClearRefinements
transformItems={(items) =>
items.filter((item) => item.attribute !== 'query')
}
/>
Customize the text strings.<ClearRefinements
translations={{
resetButtonText: 'Clear all filters',
}}
/>
CSS classes to customize the component styling.
Example
import {
InstantSearch,
ClearRefinements,
RefinementList,
SearchBox,
} from 'react-instantsearch';
import { liteClient as algoliasearch } from 'algoliasearch/lite';
const searchClient = algoliasearch(
'YourApplicationID',
'YourSearchOnlyAPIKey'
);
function App() {
return (
<InstantSearch searchClient={searchClient} indexName="products">
<SearchBox />
<ClearRefinements />
<RefinementList attribute="brand" />
<RefinementList attribute="category" />
</InstantSearch>
);
}