> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ais-clear-refinements

> Lets users reset all applied search refinements.

<div className="not-prose algolia-flavor-switcher">
  <div className="afs-dropdown">
    <div className="afs-trigger" role="button" tabIndex="0" aria-haspopup="listbox">
      <span className="afs-current">Vue</span>

      <svg className="afs-chevron lucide lucide-chevron-down" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
        <path d="m6 9 6 6 6-6" />
      </svg>
    </div>

    <ul className="afs-menu" role="listbox">
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/api-reference/widgets/clear-refinements/js"><span className="afs-option-name">JavaScript</span><span className="afs-option-lib">InstantSearch.js</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/api-reference/widgets/clear-refinements/react"><span className="afs-option-name">React</span><span className="afs-option-lib">React InstantSearch</span></a></li>
      <li role="option" aria-selected="true"><a className="afs-option is-current" href="/doc/api-reference/widgets/clear-refinements/vue"><span className="afs-option-name">Vue</span><span className="afs-option-lib">Vue InstantSearch</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/api-reference/widgets/clear-refinements/ios"><span className="afs-option-name">iOS</span><span className="afs-option-lib">InstantSearch iOS</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/api-reference/widgets/clear-refinements/android"><span className="afs-option-name">Android</span><span className="afs-option-lib">InstantSearch Android</span></a></li>
      <li role="option" aria-selected="false"><a className="afs-option" href="/doc/api-reference/widgets/clear-refinements/flutter"><span className="afs-option-name">Flutter</span><span className="afs-option-lib">Algolia for Flutter</span></a></li>
    </ul>
  </div>
</div>

```vue Signature theme={"system"}
<ais-clear-refinements
  // Optional parameters
  :excluded-attributes="string[]"
  :included-attributes="string[]"
  :transform-items="function"
  :class-names="object"
/>
```

## Import

<Tabs>
  <Tab title="Component">
    To ensure optimal bundle sizes,
    see [Optimize build size](/doc/guides/building-search-ui/going-further/improve-performance/vue#optimize-build-size).

    ```js Vue icon=code theme={"system"}
    import { AisClearRefinements } from "vue-instantsearch";
    // Use "vue-instantsearch/vue3/es" for Vue 3

    export default {
      components: {
        AisClearRefinements
      },
      // ...
    };
    ```
  </Tab>

  <Tab title="Plugin">
    This imports all widgets, even the ones you don't use.
    For more information, see [Get started with Vue InstantSearch](/doc/guides/building-search-ui/getting-started/vue).

    ```js JavaScript icon="code" theme={"system"}
    import Vue from "vue";
    import InstantSearch from "vue-instantsearch";
    // Use "vue-instantsearch/vue3/es" for Vue 3

    Vue.use(InstantSearch);
    ```
  </Tab>
</Tabs>

<Card title="See this widget in action" icon="monitor-play" href="https://instantsearchjs.netlify.app/stories/vue/?selectedKind=ais-clear-refinements" horizontal>
  Preview this widget and its behavior.
</Card>

## About this widget

The `ais-clear-refinements` widget displays a button that lets users clears every currently applied refinement.

## Examples

```vue Vue icon=code theme={"system"}
<ais-clear-refinements />
```

## Props

<ParamField body="excluded-attributes" type="string[]" default="['query']">
  The attributes to exclude from the refinements to clear.
  In the example below, the attribute `brand` is excluded from the refinements to clear.

  This can't be used with [`included-attributes`](#param-included-attributes).

  ```vue Vue icon=code theme={"system"}
  <ais-clear-refinements
    :excluded-attributes="['brand']"
  />
  ```
</ParamField>

<ParamField body="included-attributes" type="string[]" default="[]">
  The attributes to include in the refinements to clear (all by default).
  In the example below, only the `categories` attribute is included in the refinements to clear.

  This can't be used with [`excluded-attributes`](#param-excluded-attributes).

  ```vue Vue icon=code theme={"system"}
  <ais-clear-refinements
    :included-attributes="['categories']"
  />
  ```
</ParamField>

<ParamField body="transform-items" type="function" default="items => items">
  A function that receives the list of items before they are displayed.
  It should return a new array with the same structure.
  Use this to transform, filter, or reorder the items.

  The function also has access to the full `results` data,
  including all standard [response parameters](/doc/guides/building-search-ui/going-further/backend-search/in-depth/understanding-the-api-response/)
  and [parameters from the helper](https://community.algolia.com/algoliasearch-helper-js/reference.html#query-parameters),
  such as `disjunctiveFacetsRefinements`.

  <Note>
    To [prevent creating infinite loops](https://support.algolia.com/hc/en-us/articles/4406511683217-Vue-InstantSearch-How-do-I-prevent-infinite-loops),
    avoid passing arrays, objects, or functions directly in the template.
    These values aren't referentially equal on each render,
    which causes the widget to re-register every time.
    Instead, define them in your component's `data` option and reference them in the template.
  </Note>

  ```vue Vue icon=code theme={"system"}
  <template>
    <!-- ... -->
    <ais-current-refinements :transform-items="transformItems" />
  </template>

  <script>
    export default {
      methods: {
        transformItems(items) {
          return items.sort(item => item.attribute);
        },

        /* or, combined with results */
        transformItems(items, { results }) {
          return results.nbHits === 0
            ? items
            : items.filter(item => item !== 'brand');
        },
      },
    };
  </script>
  ```
</ParamField>

<ParamField body="class-names" type="object" default="{}">
  The [CSS classes you can override](/doc/guides/building-search-ui/widgets/customize-an-existing-widget/vue#style-your-widgets):

  * `ais-ClearRefinements`. The root container of the widget.
  * `ais-ClearRefinements-button`. The button of the widget.
  * `ais-ClearRefinements-button--disabled`. The disabled button of the widget.

  ```vue Vue icon=code theme={"system"}
  <ais-clear-refinements
    :class-names="{
      'ais-ClearRefinements': 'MyCustomClearRefinements',
      'ais-ClearRefinements-button': 'MyCustomClearRefinementsButton',
      // ...
    }"
  />
  ```
</ParamField>

## Customize the UI

<ParamField body="default">
  The slot to override the complete DOM output of the widget.

  When you implement this slot,
  none of the other slots will change the output,
  as the default slot surrounds them.

  **Scope**

  * `canRefine: boolean`. Are there any refinements?
  * `refine: () => void`. The function to clear all the refinements.
  * `createURL: () => string`. The function to return a link for the search without the refinements.

  ```vue Vue icon=code theme={"system"}
  <ais-clear-refinements>
    <template v-slot="{ canRefine, refine, createURL }">
      <a
        :href="createURL()"
        @click.prevent="refine"
        v-if="canRefine"
      >
        Clear all refinements
      </a>
    </template>
  </ais-clear-refinements>
  ```
</ParamField>

<ParamField body="resetLabel">
  The slot to override the DOM output for the label of the reset button.

  ```vue Vue icon=code theme={"system"}
  <ais-clear-refinements>
    <template v-slot:resetLabel>Clear refinements</template>
  </ais-clear-refinements>
  ```
</ParamField>

## HTML output

```html HTML icon=code-xml theme={"system"}
<div class="ais-ClearRefinements">
  <button class="ais-ClearRefinements-button">Clear refinements</button>
</div>
```
