Skip to main content
Signature

Import

See this widget in action

Preview this widget and its behavior.

About this widget

Requirements

Declare each facet attribute in attributesForFaceting. Configure the facet order in the Algolia dashboard or with renderingContent.facetOrdering. By default, dynamicWidgets requests all facets with facets: ["*"] and requests up to 20 values per facet. These defaults help avoid a second request after the matching widgets mount. Override these defaults with facets and maxValuesPerFacet.
dynamicWidgets requires InstantSearch.js 4.72.0 or later.

Examples

Options

string | HTMLElement
required
A CSS selector or HTMLElement that contains the widget.
Array<(container: HTMLElement) => Widget>
required
An array of functions that create refinement widgets.Each function receives a container and returns a widget. The returned widget must define an attribute or attributes option so that dynamicWidgets can match and order it.The function can also return a custom widget created with a connector.
(args: { attribute: string, container: HTMLElement }) => Widget
A function that’s called for every attribute you want to display. It receive a container and attribute and is expected to return a widget. The function can also return custom widgets created with connectors.
function
Transforms the facet attributes before rendering.The second argument includes the search results, which you can use to derive a different attribute list.
JavaScript
['*']|[]
default:"['*']"
The facets to apply before dynamic widgets are mounted. Setting the value to ['*'] requests all facets and avoids an additional network request.
number
default:20
The maximum number of values to request for each facet.Set this value to at least the highest limit or showMoreLimit used by a dynamic widget. This helps avoid an additional request after the widget mounts.Set maxValuesPerFacet to at least the largest number of pinned values configured for any facet. Otherwise, some pinned values might not appear.
JavaScript

Customize the UI with connectDynamicWidgets

Use connectDynamicWidgets to build a custom UI for dynamicWidgets. Import the connector using the method that matches your InstantSearch.js installation.
Create a render function, pass it to connectDynamicWidgets, and add the resulting widget to the search:
JavaScript

Create a render function

InstantSearch.js calls the render function before the first search during the init lifecycle and each time results come back from Algolia (render lifecycle step).
JavaScript

Rendering options

string[]
The ordered facet attributes to render, derived from renderingContent.facetOrdering.facets.order.
JavaScript
object
All original widget options forwarded to the render function.
JavaScript

Create and instantiate the custom widget

First, create your custom widgets using a rendering function. Then, instantiate them with parameters. There are two kinds of parameters you can pass:
  • Instance parameters. Predefined options that configure Algolia’s behavior.
  • Custom parameters. Parameters you define to make the widget reusable and adaptable.
Inside the renderFunction, both instance and custom parameters are accessible through connector.widgetParams.
JavaScript

Instance options

object[]
required
The widgets to add to the parent index.Update their DOM positions in the render function to match the order in attributesToRender.
JavaScript
function
A function to transform the attributes to render, or using a different source to determine the attributes to render.
JavaScript
['*']|[]
default:"['*']"
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.
number
default:20
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 maxValuesPerFacet at least as high as all the most pinned items you have.
JavaScript

Full example

HTML
JavaScript
Last modified on July 30, 2026