🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
UI libraries / Vue InstantSearch / Widgets
Signature
<ais-dynamic-widgets
  // Optional parameters
  transform-items="function"
  facets="['*']|[]"
  max-values-per-facet="number"
>
  children
</ais-dynamic-widgets>
Import
1
2
3
4
5
6
7
8
9
import { AisDynamicWidgets } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3

export default {
  components: {
    AisDynamicWidgets
  },
  // ...
};

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

ais-dynamic-widgets is a widget that displays matching widgets, based on the corresponding settings of the index and may be altered by a Rule. You can configure the facet merchandising through the corresponding index setting.

Learn how to set up ordering in the facet display guide.

Requirements

You must set the attributes for faceting and configure the facet order, either using the dashboard) or the API parameters attributesForFaceting and renderingContent.

All matching widgets mount after the first network request completes. To avoid a second network request, facets are set to ['*'] and maxValuesPerFacet is set to 20 by default.

If this behavior isn’t what you want, it can be overridden using the facets and max-values-per-facet parameters.

You must use at least Vue InstantSearch version 3.8.0 to use ais-dynamic-widgets.

Examples

1
2
3
4
5
6
7
<ais-dynamic-widgets>
  <ais-refinement-list attribute="brand" />
  <ais-panel>
    <ais-menu attribute="categories" />
  </ais-panel>
  <ais-hierarchical-menu :attributes="['categories']" />
</ais-dynamic-widgets>

Options

Parameter Description
children
type: Widget[]
Required

The children of this component will be displayed dynamically based on the result of facetOrdering. This means that any child needs to have either the “attribute” or “attributes” prop.

1
2
3
<ais-dynamic-widgets>
  <ais-refinement-list attribute="brand" />
</ais-dynamic-widgets>
transform-items
type: function
Optional

A function to transform the attributes to render, or using a different source to determine the attributes to render.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<template>
  <ais-dynamic-widgets
    :transform-items="transformItems"
  >
    <!-- ... -->
  <ais-dynamic-widgets>
</template>

<script>
export default {
  methods: {
    transformItems(items, { results }) {
      return items;
    }
  }
}
</script>
facets
type: ['*']|[]
default: ['*']
Optional

The facets to apply before dynamic widgets get mounted. Setting the value to ['*'] will request all facets and avoid an additional network request once the widgets are added.

1
2
3
4
<ais-dynamic-widgets
  // ...
  :facets="['*']"
/>
max-values-per-facet
type: number
default: 20
Optional

The default number of facet values to request. It’s recommended to have this value at least as high as the highest limit and showMoreLimit of dynamic widgets, as this will prevent a second network request once that widget mounts.

To avoid pinned items not showing in the result, make sure you choose a max-values-per-facet at least as high as all the most pinned items you have.

1
2
3
4
<ais-dynamic-widgets
  // ...
  :max-values-per-facet="500"
/>
Did you find this page helpful?