Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
See this widget in action
Preview this widget and its behavior.
About this widget
Theais-autocomplete widget provides the logic to create a connected component that provides access to all indices of your InstantSearch instance.
- To configure the number of hits to show, use the
ais-hits-per-pagewidget or theais-configurewidget. - To retrieve results from several indices, use the
ais-indexwidget.
Examples
Vue
Props
boolean
default:true
Whether to escape HTML entities from hits string values.
Vue
boolean
default:true
Whether the widget makes InstantSearch require a main search request.
By default (
true), the widget contributes to the main search.
Set it to false to opt the widget out of the main search: if it’s the only widget on the page, InstantSearch doesn’t send a main search request.Vue
object
default:"{}"
Customize the UI
The slot to override the complete DOM output of the widget.If you use this slot, the other slots don’t change the output, because the default slot surrounds them.Scope
currentRefinement: string. The current value of the query.indices: object[]. The list of indices.refine: (string) => void. The function to change the query.
highlight widget (see below).
Each index includes:indexName: string. The name of the index.indexId: string. The id of the index.hits: object[]. The resolved hits from the index matching the query.results: object. The full results object from the Algolia API.sendEvent: (eventType, hit, eventName) => void. The function to sendclickorconversionevents. Theviewevent is automatically sent when the connector renders hits. You can learn more about theinsightsmiddleware.eventType: 'click' | 'conversion'hit: Hit | Hit[]eventName: string
Vue
Prebuilt autocomplete component
Theais-experimental-autocomplete component renders a complete autocomplete menu: a search box, a panel with results from one or more indices, recent searches, Query Suggestions, prompt suggestions, and a detached layout for small screens.
It uses the same markup and most of the same options as the InstantSearch.js autocomplete widget, so see that page for details about each option.
The JavaScript container and templates options don’t apply: Vue renders the component in place, and slots replace templates.
Use class-names for cssClasses and get-search-page-url for getSearchPageURL.
The component is experimental: its name and API may change in a later version.
Vue
Vue
autofocus is true.
The component reads its props only when initialized.
Changing them later doesn’t have any effect.
Props
indicesandfeedsare mutually exclusive. Setting both throws an error.feedsrequires a composition-based InstantSearch instance withcompositionIDset.show-prompt-suggestionsandai-modesend the query to anais-chatwidget in the same index.- Write
escapeHTMLin camelCase. The kebab-case formescape-htmldoesn’t bind. class-namesuses the keys of the InstantSearch.jscssClassesoption, such asroot,panel, andpanelOpen, notais-class names.