AutoComplete components allow users to select items from a defined list. The input field acts as a search box and will narrow the list of items presented based on matches against the entered text.
AutoCompleteFilter includes a secondary dropdown that allows results to be filtered based on some criteria. For example, the data
array could contain a list of all employee names while the filterData
array enables filtering of employees by department.
A basic list of items in the filter dropdown to filter data in the autocomplete dropdown.
When the list of items in the filter gets larger, you can enable a search field in the filter dropdown. Use the showFilterSearch
property to enable searching.
To render custom content for list items and input text, use the dataRendering
property. See AutoComplete
for an example.
See AutoComplete
for an example of how to use headers, dividers or disabled items in the dropdown list.
The loadingMsg
property can be used to add a Spinner to the dropdown loading animation.
To use infinite scrolling, the consumer must provide and call the required data using the infinite
object. The onLoadMore
callback is triggered near the bottom of the dropdown to allow for more data to be fetched. The new data should be appended to the previous data
property. To stop infinite scrolling or stop fetching data, change hasMore
to false
.
Use the disabled
property to disable the AutocompleteFilter component. A disabled element is unusable and un-clickable.
ReadOnly is not a supported state for the AutocompleteFilter component.
Property | Type | Default | Description |
---|---|---|---|
noResultsMsg | String or Object | Required | Displayed when no data items match entered text. If a string is used, it will display that text. If an object is used, it has props for title (primary text) and description (secondary text). |
active | String | Id of the active data item. | |
activeFilterItemId | String | Id of the active filterData item. | |
className | String | Custom classes to be added to the <input> tag. | |
data | Array | Raw data for the dropdown items. Each element in the array (in JSON format) represents an item in the dropdown. For default rendering of list items, each item should have keys for id and text . For custom rendering of list items, see dataRendering . | |
dataRendering | Object | Enables custom rendering. See dataRendering for details about the available properties. | |
disabled | Boolean | false | Controls whether the component is enabled or disabled. |
dropdownIcon | String | 'filter' | Dropdown icon class name. Populating this field displays an icon on the dropdown button instead of the dropdownTitle label. |
dropdownTitle | String | Dropdown button label. If dropdownIcon is defined this becomes an accessible ARIA label to identify the button. | |
dropdownTriggerLabel | String | Required | Localized assistive text for the dropdown trigger button. |
filterButtonProps | Object | Properties to pass through to the filter button. | |
filterData | Array | List of possible filter selections. Array of objects with properties for id and text; e.g., { { id: 1, text: 'Filter 1' }, { id: 2, text: 'Filter 2' } } . | |
filterSearchInputProps | Object | Properties to pass through to the filter dropdown search field. | |
infinite | Object | Defines the properties for infinite scrolling. See infinite for more details. | |
isLoading | Boolean | false | When true, loadingMsg will be displayed. |
isOpen | Boolean | false | When true, the input dropdown will be opened automatically on creation. |
itemKey | String or Function | 'id' | Used to identify the unique key for a list item. If a string is used, it identifies the field in the data to use as the key value for the list item. If a function is used, it must return the key value for the list item. The function will be passed the row of data (in JSON format). |
loadingMsg | Node | Displayed while data is loading. Must be non-empty if isLoading is true. | |
mruData | Array | Raw data for the most-recently used (MRU) items (in JSON format). For simple rendering of list items, each item should have keys for id and text . For custom rendering of list items, see dataRendering . | |
mruTitle | String | Title of MRU section inside dropdown menu. | |
placeholder | String | Placeholder displayed when input field is empty. | |
popperClassName | String | Custom classes to be added to the popper <div> element. | |
popperPlacement | String or String[] | Placement of the dropdown relative to the input element. Options are 'top' , 'top-start' , 'top-end' , 'bottom' , 'bottom-start' , 'bottom-end' , 'left' , 'left-start' , 'left-end' , 'right' , 'right-start' , 'right-end' . See Popover Placement for a more detailed description of the values. | |
required | Boolean | false | Adds the required attribute to the <input> element. NOTE: This does not perform any validation, but rather just marks the field as required. |
size | String | 'lg' | Component size. Options are 'lg' , 'md' and 'sm' . |
showAllOnFocus | Boolean | true | If true, dropdown menu opens automatically when component receives focus. If false, dropdown menu will not open until at least one character is entered (or more, depending on the value of showAllOnFocusThreshold . |
showAllOnFocusThreshold | Number | 0 | Minimum number of characters that must be entered before the autocomplete menu is displayed. |
showFilterSearch | Boolean | false | When true, a field is displayed in the filter dropdown to allow searching within filterData . |
targetClassName | String | Custom classes to be added to the target/reference <div> wrapper element. | |
value | String | Initial (default) value of input field. | |
widthSizingType | String | 'minTarget' | The width of the popper component relative to the target. Options are 'none' ,'matchTarget' ,'minTarget' ,'maxTarget' |
Property | Parameters | Description |
---|---|---|
onBlur | event | Callback function for input field onBlur events. Will be called only if input field loses focus and the Dropdown popover is closed. |
onChange | event | Callback function for input field onChange events. |
onDropdownClose | event | Callback function for onDropdownClose events. |
onFilterSelect | item | Callback function for onFilterSelect events. |
onFocus | event | Callback function for input field onFocus events. |
onKeyDown | event | Callback function for input field onKeyDown events. |
onMouseDown | event | Callback function for input field onMouseDown. |
onSelect | item | Callback function for input field onSelect events. |
Property | Type | Default | Description |
---|---|---|---|
inputRenderer | String or Function | 'text' | Used to render text in the input for a selected item. If a string is used, the value for that key (from data or mruData ) will be shown. If a function is used, it must return the text to display in the input field. The function will be passed the row of data (in JSON format). |
listItemRenderer | String or Function | 'text' | Used to render content for each list item in the dropdown. If a string is used, the value for that key (from data or mruData ) will be shown. If a function is used, it must return a valid node. The function will be passed the row of data (in JSON format). |
Property | Type | Default | Description |
---|---|---|---|
hasMore | Boolean | true | Sets whether there are more items to be loaded. Event listeners are removed if set to false . This can also be used to disable infinite loading. NOTE: Setting hasMore to true emits a loading message. Having bothisLoading and hasMore set to true will result in multiple loading messages. |
isInitialLoad | Boolean | true | Sets whether the component should load the first set of items when opened. |
pageStart | Number | 0 | The number of the first page to load. With the default of 0, the first page is loaded. |
threshold | Number | 250 | The distance in pixels from the bottom of the scroll area before a call to onLoadMore is triggered. |
Property | Parameters | Description |
---|---|---|
onLoadMore | pageNumber | A callback when more items are requested by the user. Provides a single parameter specifying the page to load. |