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
The CoreUI Bootstrap Autocomplete Component provides the flexibility to personalize options and group labels by utilizing custom templates. You can easily customize the options using the `optionsTemplate`, and for groups, you can use `optionsGroupsTemplate`, as demonstrated in the examples below:
222
+
223
+
{{< example stackblitz_pro="true" stackblitz_add_js="true">}}
224
+
<divclass="row">
225
+
<divclass="col-md-6">
226
+
<div id="myAutocompleteCountries"></div>
227
+
</div>
228
+
<divclass="col-md-6">
229
+
<div id="myAutocompleteCountriesAndCities"></div>
230
+
</div>
231
+
</div>
232
+
{{< /example >}}
233
+
234
+
We use the following JavaScript to set up our autocomplete:
|`allowList`| object |`DefaultAllowlist`| Object containing allowed tags and attributes for HTML sanitization when using custom templates. |
264
285
|`allowOnlyDefinedOptions`| boolean |`false`| Restricts selection to only predefined options when set to `true`. |
265
286
|`ariaCleanerLabel`| string |`'Clear selection'`| Accessible label for the cleaner button, read by screen readers. |
266
287
|`ariaIndicatorLabel`| string |`'Toggle visibility of options menu'`| Accessible label for the indicator button, read by screen readers. |
267
288
|`cleaner`| boolean |`false`| Enables the selection cleaner button. |
268
289
|`clearSearchOnSelect`| boolean |`true`| Clears the search input when an option is selected. |
269
290
|`container`| string, element, boolean |`false`| Appends the dropdown to a specific element. Example: `container: 'body'`. |
270
291
|`disabled`| boolean |`false`| Disables the component when set to `true`. |
271
-
|`highlightOptionsOnSearch`| boolean |`true`| Highlights matching text in options during search. |
292
+
|`highlightOptionsOnSearch`| boolean |`false`| Highlights matching text in options during search. |
293
+
|`id`| string, null |`null`| Sets a custom ID for the component. If not provided, a unique ID is auto-generated. |
272
294
|`indicator`| boolean |`false`| Enables the selection indicator button. |
273
295
|`invalid`| boolean |`false`| Applies invalid styling to the component. |
274
296
|`name`| string, null |`null`| Sets the name attribute for the input element. |
275
297
|`options`| boolean, array |`false`| Array of options or option objects to populate the dropdown. |
298
+
|`optionsGroupsTemplate`| function, null |`null`| Custom template function for rendering option group labels. Receives the group object as parameter. |
276
299
|`optionsMaxHeight`| number, string |`'auto'`| Sets the maximum height of the options dropdown. |
300
+
|`optionsTemplate`| function, null |`null`| Custom template function for rendering individual options. Receives the option object as parameter. |
277
301
|`placeholder`| string, null |`null`| Placeholder text displayed in the input field. |
278
302
|`required`| boolean |`false`| Makes the input field required for form validation. |
303
+
|`sanitize`| boolean |`true`| Enables HTML sanitization for custom templates to prevent XSS attacks. |
304
+
|`sanitizeFn`| function, null |`null`| Custom sanitization function. If provided, it will be used instead of the built-in sanitizer. |
279
305
|`search`| array, string, null |`null`| Enables search functionality. Use `'global'` for global search across the component and `'external'` when options are provided from external sources. |
280
306
|`searchNoResultsLabel`| string |`false`| Text displayed when no search results are found. |
281
307
|`showHints`| boolean |`false`| Shows completion hints as users type. |
0 commit comments