🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
InstantSearch / React / V6 / API reference

ToggleRefinement | React InstantSearch V6 (Deprecated)

This version of React InstantSearch has been deprecated in favor of the latest version of React InstantSearch.

Signature# A

Signature
<ToggleRefinement
  attribute={string}
  label={string}
  value={string|number|boolean}
  // Optional parameters
  defaultRefinement={boolean}
/>

About this widget# A

The ToggleRefinement widget provides an on/off filtering feature based on an attribute value.

Requirements#

Ensure that the attribute provided is already declared as an attribute for faceting.

Examples# A

1
2
3
4
5
6
7
import { ToggleRefinement } from 'react-instantsearch-dom';

<ToggleRefinement
  attribute="free_shipping"
  label="Free Shipping"
  value={true}
/>

Props# A

attribute#

Required
Type: string

The name of the attribute on which to apply the refinement.

1
2
3
4
<ToggleRefinement
  // ...
  attribute="free_shipping"
/>

label#

Required
Type: string

The label to display for the checkbox.

1
2
3
4
<ToggleRefinement
  // ...
  label="Free Shipping"
/>

value#

Required
Type: string|number|boolean

The value to apply on the attribute when the widget is checked.

1
2
3
4
<ToggleRefinement
  // ...
  value={true}
/>

defaultRefinement#

Optional
Type: boolean

Whether the widget should be checked by default.

1
2
3
4
<ToggleRefinement
  // ...
  defaultRefinement={true}
/>
Did you find this page helpful?