> ## 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-current-refinements

> Shows applied refinements and lets users remove them.

export const Index = () => <Tooltip tip="An Algolia index is a searchable dataset that consists of records and configuration settings. These settings define how the records are searched and ranked.">
    index
  </Tooltip>;

```vue Signature theme={"system"}
<ais-current-refinements
  // Optional parameters
  :included-attributes="string[]"
  :excluded-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 { AisCurrentRefinements } from "vue-instantsearch";
    // Use "vue-instantsearch/vue3/es" for Vue 3

    export default {
      components: {
        AisCurrentRefinements
      },
      // ...
    };
    ```
  </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-current-refinements" horizontal>
  Preview this widget and its behavior.
</Card>

## About this widget

The `ais-current-refinements` widget displays a list of [refinements](/doc/api-reference/widgets/refinement-list/vue) applied to the search.

## Examples

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

## Props

<ParamField body="included-attributes" type="string[]">
  The attributes to include in the widget (all by default).
  Can't be used with [`excluded-attributes`](#param-excluded-attributes).
  In the example below, only the `categories` attribute is included in the widget.

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

<ParamField body="excluded-attributes" type="string[]" default="['query']">
  The attributes to exclude from the widget.
  Can't be used with [`included-attributes`](#param-included-attributes).
  In the example below, the `brand` attribute is excluded from the widget.

  ```vue Vue icon=code theme={"system"}
  <ais-current-refinements
    :excluded-attributes="['brand']"
  />
  ```
</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.filter((item) => item.attribute !== "brand");
      },

      // or, combined with results
      transformItems(items, { results }) {
        return results.nbHits === 0
          ? items
          : items.filter((item) => item.attribute !== "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-CurrentRefinements`. The root element of the widget.
  * `ais-CurrentRefinements--noRefinement`. The root element of the widget without refinement.
  * `ais-CurrentRefinements-list`. The list of refined items.
  * `ais-CurrentRefinements-item`. The item of the refined items list.
  * `ais-CurrentRefinements-label`. The label of the refined item.
  * `ais-CurrentRefinements-delete`. The delete button of each item.

  ```vue Vue icon=code theme={"system"}
  <ais-current-refinements
    :class-names="{
      'ais-CurrentRefinements': 'MyCustomCurrentRefinements',
      'ais-CurrentRefinements-list': 'MyCustomCurrentRefinementsList',
      // ...
    }"
  />
  ```
</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**

  * `items: object[]`. The refinements currently applied to the search.
  * `createURL: (value: object) => string`. The function to return a link for the search without this refinement.

  Where an item is an `object` containing:

  * `indexName: string`. The <Index /> name on which the refinement is applied.
  * `indexId: string`. The index id on which the refinement is applied.
  * `attribute: string`. The name of the attribute with which the refinement is applied. The value is used as the key.
  * `label: string`. The name of the attribute with which the refinement is applied. The label is used as the the display value.
  * `refine: (value: object) => void`. The function to clear a refinement.
  * `refinements: object[]`. Each of the individual refinements for this attribute.

  Where each refinement is an `object` containing:

  * `type: string`. Can be `"facet"`, `"exclude"`, `"disjunctive"`, `"hierarchical"`, `"numeric"` or `"query"`.
  * `attribute: string`. The name of the attribute where the refinement is applied. The value is used as the key.
  * `label: string`. The name of the attribute with which the refinement is applied. The label is used as the the display value.
  * `value: any`. Actual value for this refinement.

  ```vue Vue icon=code theme={"system"}
  <ais-current-refinements>
    <template v-slot="{ items, createURL }">
      <ul>
        <li v-for="item in items" :key="item.attribute">
          {{ item.label }}:
          <ul>
            <li
              v-for="refinement in item.refinements"
              :key="[
                refinement.attribute,
                refinement.type,
                refinement.value,
                refinement.operator
              ].join(':')"
            >
              <a
                :href="createURL(refinement)"
                @click.prevent="item.refine(refinement)"
              >
                {{ refinement.label }} X
              </a>
            </li>
          </ul>
        </li>
      </ul>
    </template>
  </ais-current-refinements>
  ```
</ParamField>

<ParamField body="item">
  The slot to override the DOM output of an item.

  **Scope**

  * `item: object`. One attribute with [refinements](/doc/api-reference/widgets/refinement-list/vue).
  * `refine: (value: string) => void`. The function to clear a refinement.
  * `createURL: (value: string) => void`. The function to return a link for the search without this refinement.

  Where item is an `object` containing:

  * `indexName: string`. The index name on which the refinement is applied.
  * `indexId: string`. The index id on which the refinement is applied.
  * `attribute: string`. The name of the attribute with which the refinement is applied. The value is used as the key.
  * `label: string`. The name of the attribute with which the refinement is applied. The label is used as the the display value.
  * `refine: (value: object) => void`. The function to clear a refinement.
  * `refinements: object[]` each of the individual refinements for this attribute.

  Where each refinement is an `object` containing:

  * `type: string`. Can be `"facet"`, `"exclude"`, `"disjunctive"`, `"hierarchical"`, `"numeric"` or `"query"`.
  * `attribute: string`. The name of the attribute with which the refinement is applied. The value is used as the key.
  * `label: string`. The name of the attribute with which the refinement is applied. The label is used as the the display value.
  * `value: any`. The actual value for this refinement.

  ```vue Vue icon=code theme={"system"}
  <ais-current-refinements>
    <template v-slot:item="{ item, refine, createURL }">
      {{ item.label }}:
      <ul>
        <li
          v-for="refinement in item.refinements"
          :key="[
            refinement.attribute,
            refinement.type,
            refinement.value,
            refinement.operator
          ].join(':')"
        >
          <a
            :href="createURL(refinement)"
            @click.prevent="refine(refinement)"
          >
            {{ refinement.label }} X
          </a>
        </li>
      </ul>
    </template>
  </ais-current-refinements>
  ```
</ParamField>

<ParamField body="refinement">
  The slot to override the DOM output of a sinrefinement.

  **Scope**

  * `refinement: object`. One item of the list of [refinements](/doc/api-reference/widgets/refinement-list/vue).
  * `refine: (value: string) => void`. The function to clear a refinement.
  * `createURL: (value: string) => void`. The function to return a link for the search without this refinement.

  Where refinement is an `object` containing:

  * `type: string`. Can be `"facet"`, `"exclude"`, `"disjunctive"`, `"hierarchical"`, `"numeric"` or `"query"`.
  * `attribute: string`. The name of the attribute where the refinement is applied. The value is used as the key.
  * `label: string`. The name of the attribute with which the refinement is applied. The label is used as the the display value.
  * `value: any`. The actual value for this refinement.

  ```vue Vue icon=code theme={"system"}
  <ais-current-refinements>
    <template v-slot:refinement="{ refinement, refine, createURL }">
      <a
        :href="createURL(refinement)"
        @click.prevent="refine(refinement)"
      >
        {{ refinement.label }} X
      </a>
    </template>
  </ais-current-refinements>
  ```
</ParamField>

## HTML output

```html HTML icon=code-xml theme={"system"}
<div class="ais-CurrentRefinements">
  <ul class="ais-CurrentRefinements-list">
    <li class="ais-CurrentRefinements-itemt">
      <span class="ais-CurrentRefinements-label"> Category: </span>
      <span class="ais-CurrentRefinements-category">
        <span class="ais-CurrentRefinements-categoryLabel">
          Movies & TV Shows
        </span>
        <button class="ais-CurrentRefinements-delete">✕</button>
      </span>
      <span class="ais-CurrentRefinements-category">
        <span class="ais-CurrentRefinements-categoryLabel"> Others </span>
        <button class="ais-CurrentRefinements-delete">✕</button>
      </span>
    </li>
    <li class="ais-CurrentRefinements-item">
      <span class="ais-CurrentRefinements-label"> Brand: </span>
      <span class="ais-CurrentRefinements-category">
        <span class="ais-CurrentRefinements-categoryLabel"> Algolia </span>
        <button class="ais-CurrentRefinements-delete">✕</button>
      </span>
    </li>
  </ul>
</div>
```
