ais-toggle-refinement
<ais-toggle-refinement attribute="string" label="string" // Optional parameters :on="string|number|boolean" :off="string|number|boolean" :class-names="object" />
1
2
3
4
5
6
7
8
9
import { AisToggleRefinement } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
  components: {
    AisToggleRefinement
  },
  // ...
};
    1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
    2. This imports all the widgets, even the ones you don’t use. Read the Getting started guide for more information.
  
About this widget
The ais-toggle-refinement widget provides an on/off filtering feature based on an attribute value.
Examples
1
2
3
4
<ais-toggle-refinement
  attribute="free_shipping"
  label="Free Shipping"
/>
Props
| Parameter | Description | ||
|---|---|---|---|
          
            attribute
          
         | 
        
           
                
                type: string
                
               
              
                
                        Required
                
               
          The name of the attribute on which to apply the refinement. To avoid unexpected behavior, you can’t use the same   | 
      ||
| 
           
Copy
 
 | 
      |||
          
            label
          
         | 
        
           
                
                type: string
                
               
              
                
                        Required
                
               
          The label to display for the checkbox.  | 
      ||
| 
           
Copy
 
 | 
      |||
          
            on
          
         | 
        
           
                
                type: string|number|boolean
                
               
              
                
                  default: true
                
               
              
                
                    Optional
                
               
          The value of the refinement to apply on the attribute when checked.  | 
      ||
| 
           
Copy
 
 | 
      |||
          
            off
          
         | 
        
           
                
                type: string|number|boolean
                
               
              
                
                    Optional
                
               
          The value of the refinement to apply on the attribute when unchecked.  | 
      ||
| 
           
Copy
 
 | 
      |||
          
            class-names
          
         | 
        
           
                
                type: object
                
               
              
                
                  default: {}
                
               
              
                
                    Optional
                
               
          The CSS classes you can override: 
  | 
      ||
| 
           
Copy
 
 | 
      |||
Customize the UI
| Parameter | Description | ||
|---|---|---|---|
          
            default
          
         | 
        
           The slot to override the complete DOM output of the widget. Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
  | 
      ||
| 
           
Copy
 
 | 
      |||
HTML output
1
2
3
4
5
6
7
<div class="ais-ToggleRefinement">
  <label class="ais-ToggleRefinement-label">
    <input class="ais-ToggleRefinement-checkbox" type="checkbox" />
    <span class="ais-ToggleRefinement-labelText">Free Shipping</span>
    <span class="ais-ToggleRefinement-count">18,013</span>
  </label>
</div>