You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/website/docs/autocomplete-js.md
+50-24Lines changed: 50 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,42 @@ id: autocomplete-js
3
3
title: autocomplete
4
4
---
5
5
6
-
This function creates a JavaScript autocomplete experience.
6
+
Autocomplete JS creates a virtual DOM-based autocomplete experience.
7
+
8
+
The `autocomplete` function creates an autocomplete experience and attaches it to an element of the DOM. By default, it uses [Preact 10](https://preactjs.com/guide/v10/whats-new/) to render templates.
Make sure to define an empty container in your HTML where to inject your autocomplete.
35
+
10
36
```js title="HTML"
11
37
<div id="autocomplete"></div>
12
38
```
13
39
40
+
This example uses Autocomplete with an Algolia index, along with the [`algoliasearch`](https://www.npmjs.com/package/algoliasearch) API client. All Algolia utility functions to retrieve hits and parse results are available directly in the package.
`autocomplete` accepts all the props that [`createAutocomplete`](/docs/createAutocomplete#reference) supports.
89
+
The `autocomplete` function accepts all the props that [`createAutocomplete`](/docs/createAutocomplete#reference) supports.
68
90
69
91
### `container`
70
92
71
93
> `string | HTMLElement` | **required**
72
94
73
-
The container for the Autocomplete search box. You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). The first element matching the provided selector will be used as container.
95
+
The container for the Autocomplete search box. You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
74
96
75
97
import CreateAutocompleteProps from './partials/createAutocomplete-props.md'
76
98
@@ -80,19 +102,19 @@ import CreateAutocompleteProps from './partials/createAutocomplete-props.md'
80
102
81
103
> `string | HTMLElement`
82
104
83
-
The container for the Autocomplete panel. You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). The first element matching the provided selector will be used as container.
105
+
The container for the Autocomplete panel. You can either pass a [CSS selector](https://developer.mozilla.org/docs/Web/CSS/CSS_Selectors) or an [Element](https://developer.mozilla.org/docs/Web/API/HTMLElement). If there are several containers matching the selector, Autocomplete picks up the first one.
0 commit comments