# AutoSuggest

*Category:* Components
*Section:* Selection
*Source:* https://uikit.developers.rio.cloud/#/components/autosuggests
*Captured:* 2026-04-27T14:57:32.168Z

For a more flexible and smart search we highly recommend using fuse.js as searching algorithm.For more information on how to configure it, see: https://fusejs.io

## AutoSuggest

### Example: Example 1

Simple examples without searching algorithm Basic use

Suggestion 1
Suggestion 2
Suggestion 3
Suggestion 4
Suggestion 5
Suggestion 6
Suggestion 7
Suggestion 8
Suggestion 9
Suggestion 10

with loading indicator

with input-group-addon and no closeOnSelect
.00

Suggestion 1
Suggestion 2
Suggestion 3
Suggestion 4
Suggestion 5
Suggestion 6
Suggestion 7
Suggestion 8
Suggestion 9
Suggestion 10

Disabled Autosuggest

Autosuggest with error
Suggestion 1
Suggestion 2
Suggestion 3
Suggestion 4
Suggestion 5
Suggestion 6
Suggestion 7
Suggestion 8
Suggestion 9
Suggestion 10

Autosuggest with warning and addons

Suggestion 1
Suggestion 2
Suggestion 3
Suggestion 4
Suggestion 5
Suggestion 6
Suggestion 7
Suggestion 8
Suggestion 9
Suggestion 10 There is something wrong here

Autosuggest with drop up and right aligned
Suggestion 1
Suggestion 2
Suggestion 3
Suggestion 4
Suggestion 5
Suggestion 6
Suggestion 7
Suggestion 8
Suggestion 9
Suggestion 10

#### React (tsx)

```tsx
import { useState } from 'react';

import AutoSuggest, { type AutoSuggestSuggestion } from '@rio-cloud/rio-uikit/AutoSuggest';

const simpleSuggestions = Array.from(
    { length: 10 },
    (_, index) =>
        ({
            label: `Suggestion ${index + 1}`,
        }) as AutoSuggestSuggestion
);

const SimpleAutoSuggestExample = () => {
    const [value, setValue] = useState('');
    const [suggestions, setSuggestions] = useState<AutoSuggestSuggestion[]>([]);

    // Autosuggest will call this function every time you need to update suggestions.
    // It will also be called when the input is cleared. The value would be an empty string in this case.
    const handleSuggestionsFetchRequested = (result: { value: string }) => {
        const newValue = result.value;
        setValue(newValue);
        setSuggestions(
            simpleSuggestions.filter(suggestion => suggestion.label?.toLowerCase().includes(newValue.toLowerCase()))
        );
    };

    // Use your imagination to render suggestions.
    const renderSuggestion = (suggestion: AutoSuggestSuggestion) => <span>{suggestion.label}</span>;

    const inputProps = {
        icon: 'rioglyph rioglyph-search',
        placeholder: 'Start typing',
        value,
    };

    return (
        <div className='row'>
            <div className='col-sm-6 col-md-4 form-group'>
                <label htmlFor='1'>Basic use</label>
                <AutoSuggest
                    id='1'
                    inputProps={inputProps}
                    suggestions={suggestions}
                    noItemMessage='This does not look like anything to me'
                    onSuggestionsFetchRequested={handleSuggestionsFetchRequested}
                    renderSuggestion={renderSuggestion}
                    openOnFocus
                />
            </div>

            <div className='col-sm-6 col-md-4 form-group'>
                <label htmlFor='2'>with loading indicator</label>
                <AutoSuggest id='2' isLoading />
            </div>

            <div className='col-sm-6 col-md-4 form-group'>
                <label htmlFor='3'>with input-group-addon and no closeOnSelect</label>
                <AutoSuggest
                    id='3'
                    trailingInputAddons={[
                        <div key='addon-1' className='input-group-addon'>
                            .00
                        </div>,
                    ]}
                    inputProps={inputProps}
                    suggestions={suggestions}
                    noItemMessage='This does not look like anything to me'
                    onSuggestionsFetchRequested={handleSuggestionsFetchRequested}
                    onSuggestionHighlighted={(highlightedSuggestion: AutoSuggestSuggestion | null) =>
                        console.log(highlightedSuggestion)
                    }
                    renderSuggestion={renderSuggestion}
                    closeOnSelect={false}
                />
            </div>

            <div className='col-sm-6 col-md-4 form-group'>
                <label htmlFor='4'>Disabled Autosuggest</label>
                <AutoSuggest id='4' inputProps={{ disabled: true }} />
            </div>

            <div className='col-sm-6 col-md-4'>
                <div className='form-group has-feedback has-error'>
                    <label htmlFor='5'>Autosuggest with error</label>
                    <AutoSuggest id='5' inputProps={{ hasError: true }} suggestions={suggestions} />
                    <span className='form-control-feedback rioglyph rioglyph-error-sign' />
                </div>
            </div>

            <div className='col-sm-6 col-md-4'>
                <div className='form-group has-feedback has-warning'>
                    <label htmlFor='7'>Autosuggest with warning and addons</label>
                    <AutoSuggest
                        id='7'
                        inputProps={{ hasError: true, ...inputProps }}
                        suggestions={suggestions}
                        onSuggestionsFetchRequested={handleSuggestionsFetchRequested}
                        trailingInputAddons={[
                            <div key='remove' className='input-group-addon' onClick={() => {}}>
                                <span className='rioglyph rioglyph-trash cursor-pointer text-color-gray hover-text-color-danger' />
                            </div>,
                        ]}
                    />
                    <span className='form-control-feedback margin-right-25'>
                        <span className='rioglyph rioglyph-warning-sign margin-right-10' />
                    </span>
                    <span className='help-block'>There is something wrong here</span>
                </div>
            </div>

            <div className='col-sm-6 col-md-4'>
                <div className='form-group display-flex flex-column align-items-end'>
                    <label htmlFor='6'>Autosuggest with drop up and right aligned</label>
                    <div className=''>
                        <AutoSuggest id='6' className='width-150' suggestions={suggestions} pullRight dropup />
                    </div>
                </div>
            </div>
        </div>
    );
};

export default SimpleAutoSuggestExample;
```

#### HTML (html)

```html
<div>
    <div class="form-group">
        <label>Simple examples without searching algorithm</label>
        <div class="row">
            <div class="col-sm-6 col-md-4 form-group">
                <label for="1">Basic use</label>
                <div class="AutoSuggest dropdown">
                    <div class="input-group width-100pct">
                        <span class="input-group-addon">
                            <span class="rioglyph rioglyph rioglyph-search" aria-hidden="true">
                            </span>
                        </span>
                        <div class="ClearableInput input-group">
                            <input id="1" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                            <span class="clearButton hide">
                                <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                                </span>
                            </span>
                        </div>
                    </div>
                    <ul role="menu" class="dropdown-menu">
                        <li role="presentation" class="" data-item-index="0">
                            <a role="menuitem">
                                <span>Suggestion 1</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="1">
                            <a role="menuitem">
                                <span>Suggestion 2</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="2">
                            <a role="menuitem">
                                <span>Suggestion 3</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="3">
                            <a role="menuitem">
                                <span>Suggestion 4</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="4">
                            <a role="menuitem">
                                <span>Suggestion 5</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="5">
                            <a role="menuitem">
                                <span>Suggestion 6</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="6">
                            <a role="menuitem">
                                <span>Suggestion 7</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="7">
                            <a role="menuitem">
                                <span>Suggestion 8</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="8">
                            <a role="menuitem">
                                <span>Suggestion 9</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="9">
                            <a role="menuitem">
                                <span>Suggestion 10</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="col-sm-6 col-md-4 form-group">
                <label for="2">with loading indicator</label>
                <div class="AutoSuggest dropdown">
                    <div class="ClearableInput input-group">
                        <input id="2" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                        <span class="clearButton hide">
                            <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                            </span>
                        </span>
                    </div>
                    <ul class="dropdown-menu">
                        <div class="display-flex justify-content-center padding-10">
                            <div class="spinnerInfoBox display-flex justify-content-center align-items-center height-100pct">
                                <div class="spinner">
                                    <div>
                                    </div>
                                    <div>
                                    </div>
                                    <div>
                                    </div>
                                    <div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </ul>
                </div>
            </div>
            <div class="col-sm-6 col-md-4 form-group">
                <label for="3">with input-group-addon and no closeOnSelect</label>
                <div class="AutoSuggest dropdown">
                    <div class="input-group width-100pct">
                        <span class="input-group-addon">
                            <span class="rioglyph rioglyph rioglyph-search" aria-hidden="true">
                            </span>
                        </span>
                        <div class="ClearableInput input-group">
                            <input id="3" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                            <span class="clearButton hide">
                                <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                                </span>
                            </span>
                        </div>
                        <div class="input-group-addon">.00</div>
                    </div>
                    <ul role="menu" class="dropdown-menu">
                        <li role="presentation" class="" data-item-index="0">
                            <a role="menuitem">
                                <span>Suggestion 1</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="1">
                            <a role="menuitem">
                                <span>Suggestion 2</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="2">
                            <a role="menuitem">
                                <span>Suggestion 3</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="3">
                            <a role="menuitem">
                                <span>Suggestion 4</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="4">
                            <a role="menuitem">
                                <span>Suggestion 5</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="5">
                            <a role="menuitem">
                                <span>Suggestion 6</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="6">
                            <a role="menuitem">
                                <span>Suggestion 7</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="7">
                            <a role="menuitem">
                                <span>Suggestion 8</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="8">
                            <a role="menuitem">
                                <span>Suggestion 9</span>
                            </a>
                        </li>
                        <li role="presentation" class="" data-item-index="9">
                            <a role="menuitem">
                                <span>Suggestion 10</span>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
            <div class="col-sm-6 col-md-4 form-group">
                <label for="4">Disabled Autosuggest</label>
                <div class="AutoSuggest dropdown">
                    <div class="ClearableInput input-group pointer-events-none">
                        <input id="4" class="form-control disabled" autocomplete="off" type="text" disabled="" tabindex="0" value="">
                        <span class="clearButton hide">
                            <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                            </span>
                        </span>
                    </div>
                </div>
            </div>
            <div class="col-sm-6 col-md-4">
                <div class="form-group has-feedback has-error">
                    <label for="5">Autosuggest with error</label>
                    <div class="AutoSuggest dropdown">
                        <div class="ClearableInput input-group has-error">
                            <input id="5" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                            <span class="clearButton hide">
                                <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                                </span>
                            </span>
                        </div>
                        <ul role="menu" class="dropdown-menu">
                            <li role="presentation" class="" data-item-index="0">
                                <a role="menuitem">Suggestion 1</a>
                            </li>
                            <li role="presentation" class="" data-item-index="1">
                                <a role="menuitem">Suggestion 2</a>
                            </li>
                            <li role="presentation" class="" data-item-index="2">
                                <a role="menuitem">Suggestion 3</a>
                            </li>
                            <li role="presentation" class="" data-item-index="3">
                                <a role="menuitem">Suggestion 4</a>
                            </li>
                            <li role="presentation" class="" data-item-index="4">
                                <a role="menuitem">Suggestion 5</a>
                            </li>
                            <li role="presentation" class="" data-item-index="5">
                                <a role="menuitem">Suggestion 6</a>
                            </li>
                            <li role="presentation" class="" data-item-index="6">
                                <a role="menuitem">Suggestion 7</a>
                            </li>
                            <li role="presentation" class="" data-item-index="7">
                                <a role="menuitem">Suggestion 8</a>
                            </li>
                            <li role="presentation" class="" data-item-index="8">
                                <a role="menuitem">Suggestion 9</a>
                            </li>
                            <li role="presentation" class="" data-item-index="9">
                                <a role="menuitem">Suggestion 10</a>
                            </li>
                        </ul>
                    </div>
                    <span class="form-control-feedback rioglyph rioglyph-error-sign">
                    </span>
                </div>
            </div>
            <div class="col-sm-6 col-md-4">
                <div class="form-group has-feedback has-warning">
                    <label for="7">Autosuggest with warning and addons</label>
                    <div class="AutoSuggest dropdown">
                        <div class="input-group width-100pct">
                            <span class="input-group-addon">
                                <span class="rioglyph rioglyph rioglyph-search" aria-hidden="true">
                                </span>
                            </span>
                            <div class="ClearableInput input-group has-error">
                                <input id="7" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                                <span class="clearButton hide">
                                    <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                                    </span>
                                </span>
                            </div>
                            <div class="input-group-addon">
                                <span class="rioglyph rioglyph-trash cursor-pointer text-color-gray hover-text-color-danger">
                                </span>
                            </div>
                        </div>
                        <ul role="menu" class="dropdown-menu">
                            <li role="presentation" class="" data-item-index="0">
                                <a role="menuitem">Suggestion 1</a>
                            </li>
                            <li role="presentation" class="" data-item-index="1">
                                <a role="menuitem">Suggestion 2</a>
                            </li>
                            <li role="presentation" class="" data-item-index="2">
                                <a role="menuitem">Suggestion 3</a>
                            </li>
                            <li role="presentation" class="" data-item-index="3">
                                <a role="menuitem">Suggestion 4</a>
                            </li>
                            <li role="presentation" class="" data-item-index="4">
                                <a role="menuitem">Suggestion 5</a>
                            </li>
                            <li role="presentation" class="" data-item-index="5">
                                <a role="menuitem">Suggestion 6</a>
                            </li>
                            <li role="presentation" class="" data-item-index="6">
                                <a role="menuitem">Suggestion 7</a>
                            </li>
                            <li role="presentation" class="" data-item-index="7">
                                <a role="menuitem">Suggestion 8</a>
                            </li>
                            <li role="presentation" class="" data-item-index="8">
                                <a role="menuitem">Suggestion 9</a>
                            </li>
                            <li role="presentation" class="" data-item-index="9">
                                <a role="menuitem">Suggestion 10</a>
                            </li>
                        </ul>
                    </div>
                    <span class="form-control-feedback margin-right-25">
                        <span class="rioglyph rioglyph-warning-sign margin-right-10">
                        </span>
                    </span>
                    <span class="help-block">There is something wrong here</span>
                </div>
            </div>
            <div class="col-sm-6 col-md-4">
                <div class="form-group display-flex flex-column align-items-end">
                    <label for="6">Autosuggest with drop up and right aligned</label>
                    <div class="">
                        <div class="AutoSuggest dropdown dropup width-150">
                            <div class="ClearableInput input-group">
                                <input id="6" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                                <span class="clearButton hide">
                                    <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                                    </span>
                                </span>
                            </div>
                            <ul role="menu" class="dropdown-menu pull-right">
                                <li role="presentation" class="" data-item-index="0">
                                    <a role="menuitem">Suggestion 1</a>
                                </li>
                                <li role="presentation" class="" data-item-index="1">
                                    <a role="menuitem">Suggestion 2</a>
                                </li>
                                <li role="presentation" class="" data-item-index="2">
                                    <a role="menuitem">Suggestion 3</a>
                                </li>
                                <li role="presentation" class="" data-item-index="3">
                                    <a role="menuitem">Suggestion 4</a>
                                </li>
                                <li role="presentation" class="" data-item-index="4">
                                    <a role="menuitem">Suggestion 5</a>
                                </li>
                                <li role="presentation" class="" data-item-index="5">
                                    <a role="menuitem">Suggestion 6</a>
                                </li>
                                <li role="presentation" class="" data-item-index="6">
                                    <a role="menuitem">Suggestion 7</a>
                                </li>
                                <li role="presentation" class="" data-item-index="7">
                                    <a role="menuitem">Suggestion 8</a>
                                </li>
                                <li role="presentation" class="" data-item-index="8">
                                    <a role="menuitem">Suggestion 9</a>
                                </li>
                                <li role="presentation" class="" data-item-index="9">
                                    <a role="menuitem">Suggestion 10</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
```

#### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| suggestions | Array | [] | Array of items which will be displayed. Items can be arbitrary objects as long as they have a label defined. |
| onSuggestionsFetchRequested | Function | () => {} | Callback function which will be called every time you need to recalculate suggestions e.i. when the filter is updates after each input. It will also be called when the input is cleared. The value would be an empty string in this case. |
| onSuggestionSelected | Function | — | Callback function which will be called when a suggestion is selected from the dropdown menu. |
| onSuggestionHighlighted | Function | — | Callback function which will be called every time the highlighted selection changes. |
| renderSuggestion | Function | (suggestion) => suggestion.label | Function that defines how suggestions are rendered on the dropdown-menu.Use this to customize the appearance for instance when you want to show an icon for a suggestion. |
| getSuggestionValue | Function | (suggestion) => suggestion.label | Function that returns a string which will be displayed inside the input. This is required when a custom render function for suggestions is provided. Overwrite this function to provide the value to be used for a suggestion. |
| pullRight | Boolean | false | Defines whether the dropdown opens right aligned or not. Set to true additionally disables autoDrop feature. |
| dropup | Boolean | false | Boolean that disabled autoDropDirection and opens the dropdown-menu be above the toggle. |
| autoDropDirection | Boolean | true | Boolean that enables autoDrop feature. |
| closeOnSelect | Boolean | true | Boolean that enables the selection of an item to close the dropdown or not. |
| openOnFocus | Boolean | false | Boolean that enables opening the dropdown menu when gaining focus. |
| noItemMessage | String / Node | — | Text that will be shown when there is not match found. If nothing is defined the dropdown-menu will not be rendered. |
| dropdownClassName | String | — | Additional class names that are added to the dropdown element. |
| className | String | — | Additional class names that are added to the wrapping element. |
| autoComplete | String | — | Sets autocomplete value for autosuggest forms. |
| isLoading | Boolean | false | Shows a loading spinner instead of the items if set to true. |
| showSelectedItemsInInput | Boolean | true | Defines whether or not a selected item is shown in the input after it was selected. |
| leadingInputAddons | Array of Nodes | — | Adds a list of input-addons elements in front of the input. |
| trailingInputAddons | Array of Nodes | — | Adds a list of input-addons elements after the input. |

#### Props: Additional props to be passed to the underlying ClearableInput component:

### Additional props to be passed to the underlying ClearableInput component:

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| inputProps | Object | — | Object to define properties for the input component. For the input, the ClearableInput component is used. The following props are part of the inputProps: |
| └value | String | — | The value to be set for the input. Like this the input can be controlled from the outside. |
| └onChange(deprecated) | Function | () => {} | DEPRECATED - Callback function which will be called when the input changes. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onClear | Function | () => {} | Callback function which will be called when the input is cleared. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onBlur | Function | () => {} | Callback function which gets triggered when the input looses the focus. |
| └onFocus | Function | () => {} | Callback function which gets triggered when the input gaines focus. |
| └placeholder | String | Start typing ... | String that will be displayed inside the input when nothing is typed in. Default: Start typing ... |
| └icon | String | — | Icon class name that shall be used. If defined, the input element is wrapped in an input-group and the icon will be set in an input-addon. Example: rioglyph-search |
| └disabled | Boolean | false | Boolean value that disabled the input component. |
| └hasError | Boolean | false | Boolean value that adds the class has-error to the input component. Use this for validation use cases. The Autosuggest component should be wrapped in a form-group element with the class has-feedback |
| └tabIndex | Number | 0 | The tabindex attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation. See tabIndex |
| └inputRef | Function | — | The React ref for the underlying input. |
| └className | String | — | Additional class names that are added to the input component. |

## Selecting multiple items

### Example: Example 2

Example for selecting multiple items
suggestion 1
suggestion 2
suggestion 3
suggestion 4
suggestion 5
suggestion 6
suggestion 7
suggestion 8
suggestion 9

#### React (tsx)

```tsx
import { useState, useEffect } from 'react';

import AutoSuggest, { type AutoSuggestSuggestion, type SelectedSuggestion } from '@rio-cloud/rio-uikit/AutoSuggest';
import Tag from '@rio-cloud/rio-uikit/Tag';
import TagList from '@rio-cloud/rio-uikit/TagList';

const defaultSuggestions = Array.from(
    { length: 9 },
    (_, index) =>
        ({
            label: `suggestion ${index + 1}`,
        }) as AutoSuggestSuggestion
);

const removeItemByLabel = (itemToRemove: AutoSuggestSuggestion, itemList: AutoSuggestSuggestion[]) =>
    itemList.filter(item => item.label !== itemToRemove.label);

const filterSuggestions = (suggestions: AutoSuggestSuggestion[], selectedItemLabels: string[], value: string) =>
    suggestions.filter(suggestion => {
        const label = suggestion.label;
        if (!label) {
            return false;
        }
        return label.includes(value) && !selectedItemLabels.includes(label) && !suggestion.header;
    });

const MultiAutoSuggestExample = () => {
    const [selectedItems, setSelectedItems] = useState<AutoSuggestSuggestion[]>([]);
    const [inputValue, setInputValue] = useState('');
    const [currentSuggestions, setCurrentSuggestions] = useState<AutoSuggestSuggestion[]>(defaultSuggestions);

    useEffect(() => {
        const selectedItemLabels = selectedItems.map(item => item.label);
        const value = inputValue || '';

        const filteredList = filterSuggestions(defaultSuggestions, selectedItemLabels, value);
        setCurrentSuggestions(filteredList);
    }, [selectedItems, inputValue, defaultSuggestions]);

    const handleSuggestionSelected = (_: unknown, selectedSuggestion: SelectedSuggestion) => {
        setSelectedItems([...selectedItems, selectedSuggestion.suggestion]);
        setCurrentSuggestions(removeItemByLabel(selectedSuggestion.suggestion, currentSuggestions));
    };

    const handleRemoveSelectedItem = (itemToRemove: AutoSuggestSuggestion) => {
        setSelectedItems(removeItemByLabel(itemToRemove, selectedItems));
        const result = defaultSuggestions.find(item => item.label === itemToRemove.label)!;
        setCurrentSuggestions([...currentSuggestions, result]);
        setInputValue('');
    };

    const handleChangeValue = ({ value }: { value: string }) => {
        setInputValue(value);
    };

    const inputProps = {
        onChange: (_: any, data: any) => console.log(data),
        placeholder: 'Start typing',
        value: inputValue,
    };

    return (
        <>
            <AutoSuggest
                id='multiAutoSuggest'
                inputProps={inputProps}
                suggestions={currentSuggestions}
                noItemMessage='This does not look like anything to me'
                onSuggestionSelected={handleSuggestionSelected}
                onSuggestionsFetchRequested={handleChangeValue}
                openOnFocus
                className='max-width-800'
            />
            <TagList className='margin-top-15'>
                {selectedItems.map(item => (
                    <Tag
                        key={item.label}
                        className='bg-lightest'
                        size='small'
                        round={false}
                        deletable
                        onClick={() => handleRemoveSelectedItem(item)}
                    >
                        {item.label}
                    </Tag>
                ))}
            </TagList>
        </>
    );
};

export default MultiAutoSuggestExample;
```

#### HTML (html)

```html
<div>
    <div class="form-group">
        <label for="multiAutoSuggest">Example for selecting multiple items</label>
        <div class="AutoSuggest dropdown dropup max-width-800">
            <div class="ClearableInput input-group">
                <input id="multiAutoSuggest" placeholder="Start typing" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                <span class="clearButton hide">
                    <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                    </span>
                </span>
            </div>
            <ul role="menu" class="dropdown-menu">
                <li role="presentation" class="" data-item-index="0">
                    <a role="menuitem">suggestion 1</a>
                </li>
                <li role="presentation" class="" data-item-index="1">
                    <a role="menuitem">suggestion 2</a>
                </li>
                <li role="presentation" class="" data-item-index="2">
                    <a role="menuitem">suggestion 3</a>
                </li>
                <li role="presentation" class="" data-item-index="3">
                    <a role="menuitem">suggestion 4</a>
                </li>
                <li role="presentation" class="" data-item-index="4">
                    <a role="menuitem">suggestion 5</a>
                </li>
                <li role="presentation" class="" data-item-index="5">
                    <a role="menuitem">suggestion 6</a>
                </li>
                <li role="presentation" class="" data-item-index="6">
                    <a role="menuitem">suggestion 7</a>
                </li>
                <li role="presentation" class="" data-item-index="7">
                    <a role="menuitem">suggestion 8</a>
                </li>
                <li role="presentation" class="" data-item-index="8">
                    <a role="menuitem">suggestion 9</a>
                </li>
            </ul>
        </div>
        <div class="taglist taglist-autowidth margin-top-15">
        </div>
    </div>
</div>
```

#### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| suggestions | Array | [] | Array of items which will be displayed. Items can be arbitrary objects as long as they have a label defined. |
| onSuggestionsFetchRequested | Function | () => {} | Callback function which will be called every time you need to recalculate suggestions e.i. when the filter is updates after each input. It will also be called when the input is cleared. The value would be an empty string in this case. |
| onSuggestionSelected | Function | — | Callback function which will be called when a suggestion is selected from the dropdown menu. |
| onSuggestionHighlighted | Function | — | Callback function which will be called every time the highlighted selection changes. |
| renderSuggestion | Function | (suggestion) => suggestion.label | Function that defines how suggestions are rendered on the dropdown-menu.Use this to customize the appearance for instance when you want to show an icon for a suggestion. |
| getSuggestionValue | Function | (suggestion) => suggestion.label | Function that returns a string which will be displayed inside the input. This is required when a custom render function for suggestions is provided. Overwrite this function to provide the value to be used for a suggestion. |
| pullRight | Boolean | false | Defines whether the dropdown opens right aligned or not. Set to true additionally disables autoDrop feature. |
| dropup | Boolean | false | Boolean that disabled autoDropDirection and opens the dropdown-menu be above the toggle. |
| autoDropDirection | Boolean | true | Boolean that enables autoDrop feature. |
| closeOnSelect | Boolean | true | Boolean that enables the selection of an item to close the dropdown or not. |
| openOnFocus | Boolean | false | Boolean that enables opening the dropdown menu when gaining focus. |
| noItemMessage | String / Node | — | Text that will be shown when there is not match found. If nothing is defined the dropdown-menu will not be rendered. |
| dropdownClassName | String | — | Additional class names that are added to the dropdown element. |
| className | String | — | Additional class names that are added to the wrapping element. |
| autoComplete | String | — | Sets autocomplete value for autosuggest forms. |
| isLoading | Boolean | false | Shows a loading spinner instead of the items if set to true. |
| showSelectedItemsInInput | Boolean | true | Defines whether or not a selected item is shown in the input after it was selected. |
| leadingInputAddons | Array of Nodes | — | Adds a list of input-addons elements in front of the input. |
| trailingInputAddons | Array of Nodes | — | Adds a list of input-addons elements after the input. |

#### Props: Additional props to be passed to the underlying ClearableInput component:

### Additional props to be passed to the underlying ClearableInput component:

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| inputProps | Object | — | Object to define properties for the input component. For the input, the ClearableInput component is used. The following props are part of the inputProps: |
| └value | String | — | The value to be set for the input. Like this the input can be controlled from the outside. |
| └onChange(deprecated) | Function | () => {} | DEPRECATED - Callback function which will be called when the input changes. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onClear | Function | () => {} | Callback function which will be called when the input is cleared. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onBlur | Function | () => {} | Callback function which gets triggered when the input looses the focus. |
| └onFocus | Function | () => {} | Callback function which gets triggered when the input gaines focus. |
| └placeholder | String | Start typing ... | String that will be displayed inside the input when nothing is typed in. Default: Start typing ... |
| └icon | String | — | Icon class name that shall be used. If defined, the input element is wrapped in an input-group and the icon will be set in an input-addon. Example: rioglyph-search |
| └disabled | Boolean | false | Boolean value that disabled the input component. |
| └hasError | Boolean | false | Boolean value that adds the class has-error to the input component. Use this for validation use cases. The Autosuggest component should be wrapped in a form-group element with the class has-feedback |
| └tabIndex | Number | 0 | The tabindex attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation. See tabIndex |
| └inputRef | Function | — | The React ref for the underlying input. |
| └className | String | — | Additional class names that are added to the input component. |

## Detailed example with flexible matching

For a more flexible and smart search we highly recommend using fuse.js as searching algorithm. For more information on how to configure it, see: https://fusejs.io

### Example: Example 3

Full example, with fusejs suggestion rendering

Driver A-47
Driver B-52
Driver T-800
Truck D-800
Truck Y-ME
Truck Z-FG
Truck R-BM

#### React (tsx)

```tsx
import { useState } from 'react';
import Fuse from 'fuse.js';

import AutoSuggest, { type AutoSuggestSuggestion, type SelectedSuggestion } from '@rio-cloud/rio-uikit/AutoSuggest';
import Notification from '@rio-cloud/rio-uikit/Notification';

type CustomSuggestion = AutoSuggestSuggestion & {
    vehicleName: string;
    type: string;
};

const allSuggestions: CustomSuggestion[] = [
    {
        vehicleName: 'Driver A-47',
        type: 'driver',
    },
    {
        vehicleName: 'Driver B-52',
        type: 'driver',
    },
    {
        vehicleName: 'Driver T-800',
        type: 'driver',
    },
    {
        vehicleName: 'Truck D-800',
        type: 'truck',
    },
    {
        vehicleName: 'Truck Y-ME',
        type: 'truck',
    },
    {
        vehicleName: 'Truck Z-FG',
        type: 'truck',
    },
    {
        vehicleName: 'Truck R-BM',
        type: 'truck',
    },
];

// Teach AutoSuggest how to calculate suggestions for any given input value.
const getSuggestions = (value: string) => {
    const options = {
        location: 0,
        threshold: 0.5,
        distance: 100,
        minMatchCharLength: 1,
        keys: ['vehicleName', 'type'],
    };
    const fuse = new Fuse(allSuggestions, options);
    return !value ? allSuggestions : fuse.search(value).map(result => result.item);
};

const ComplexAutoSuggestExample = () => {
    const [value, setValue] = useState('');
    const [suggestions, setSuggestions] = useState<CustomSuggestion[]>([]);

    // Autosuggest will call this function every time you need to update suggestions.
    const handleSuggestionsFetchRequested = ({ value }: { value: string }) => {
        setValue(value);
        setSuggestions(getSuggestions(value));
    };

    const handleSuggestionSelected = (_: any, { suggestionValue }: SelectedSuggestion) => {
        Notification.info(suggestionValue);
    };

    // Only needed when you want to react on the event, otherwise skip it
    const handleBlur = () => console.log('focus lost');

    // Only needed when you want to react on the event, otherwise skip it
    const handleFocus = () => console.log('gained focus');

    // Use your imagination to render custom suggestions
    const renderSuggestion = (suggestion: AutoSuggestSuggestion) => {
        const { vehicleName, type } = suggestion as CustomSuggestion;
        return (
            <span key={vehicleName} className='display-flex align-items-center gap-3'>
                <span className={`rioglyph rioglyph-${type}`} />
                <span>{vehicleName}</span>
            </span>
        );
    };

    const inputProps = {
        id: 'complexAutoSuggest',
        onBlur: handleBlur,
        onFocus: handleFocus,
        className: '',
        placeholder: 'Search content',
        icon: 'rioglyph-search',
        hasError: false,
        value,
    };

    return (
        <AutoSuggest
            className='form-group max-width-800'
            dropdownClassName='foobar'
            inputProps={inputProps}
            suggestions={suggestions}
            noItemMessage='Computer says no'
            onSuggestionsFetchRequested={handleSuggestionsFetchRequested}
            onSuggestionSelected={handleSuggestionSelected}
            // Optional custom selection handler if the selection is more complex or uses different suggestion keys
            // getSuggestionValue={(suggestion: AutoSuggestSuggestion) => (suggestion as CustomSuggestion).type}
            renderSuggestion={renderSuggestion}
            customSuggestionKey='vehicleName'
        />
    );
};

export default ComplexAutoSuggestExample;
```

#### HTML (html)

```html
<div>
    <div class="form-group">
        <label for="complexAutoSuggest">Full example, with fusejs suggestion rendering</label>
        <div class="AutoSuggest dropdown dropup form-group max-width-800">
            <div class="input-group width-100pct">
                <span class="input-group-addon">
                    <span class="rioglyph rioglyph-search" aria-hidden="true">
                    </span>
                </span>
                <div class="ClearableInput input-group">
                    <input id="complexAutoSuggest" placeholder="Search content" class="form-control" autocomplete="off" type="text" tabindex="0" value="">
                    <span class="clearButton hide">
                        <span class="clearButtonIcon rioglyph rioglyph-remove-sign">
                        </span>
                    </span>
                </div>
            </div>
            <ul role="menu" class="dropdown-menu foobar">
                <li role="presentation" class="" data-item-index="0">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-driver">
                            </span>
                            <span>Driver A-47</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="1">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-driver">
                            </span>
                            <span>Driver B-52</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="2">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-driver">
                            </span>
                            <span>Driver T-800</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="3">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-truck">
                            </span>
                            <span>Truck D-800</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="4">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-truck">
                            </span>
                            <span>Truck Y-ME</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="5">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-truck">
                            </span>
                            <span>Truck Z-FG</span>
                        </span>
                    </a>
                </li>
                <li role="presentation" class="" data-item-index="6">
                    <a role="menuitem">
                        <span class="display-flex align-items-center gap-3">
                            <span class="rioglyph rioglyph-truck">
                            </span>
                            <span>Truck R-BM</span>
                        </span>
                    </a>
                </li>
            </ul>
        </div>
    </div>
</div>
```

#### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| suggestions | Array | [] | Array of items which will be displayed. Items can be arbitrary objects as long as they have a label defined. |
| onSuggestionsFetchRequested | Function | () => {} | Callback function which will be called every time you need to recalculate suggestions e.i. when the filter is updates after each input. It will also be called when the input is cleared. The value would be an empty string in this case. |
| onSuggestionSelected | Function | — | Callback function which will be called when a suggestion is selected from the dropdown menu. |
| onSuggestionHighlighted | Function | — | Callback function which will be called every time the highlighted selection changes. |
| renderSuggestion | Function | (suggestion) => suggestion.label | Function that defines how suggestions are rendered on the dropdown-menu.Use this to customize the appearance for instance when you want to show an icon for a suggestion. |
| getSuggestionValue | Function | (suggestion) => suggestion.label | Function that returns a string which will be displayed inside the input. This is required when a custom render function for suggestions is provided. Overwrite this function to provide the value to be used for a suggestion. |
| pullRight | Boolean | false | Defines whether the dropdown opens right aligned or not. Set to true additionally disables autoDrop feature. |
| dropup | Boolean | false | Boolean that disabled autoDropDirection and opens the dropdown-menu be above the toggle. |
| autoDropDirection | Boolean | true | Boolean that enables autoDrop feature. |
| closeOnSelect | Boolean | true | Boolean that enables the selection of an item to close the dropdown or not. |
| openOnFocus | Boolean | false | Boolean that enables opening the dropdown menu when gaining focus. |
| noItemMessage | String / Node | — | Text that will be shown when there is not match found. If nothing is defined the dropdown-menu will not be rendered. |
| dropdownClassName | String | — | Additional class names that are added to the dropdown element. |
| className | String | — | Additional class names that are added to the wrapping element. |
| autoComplete | String | — | Sets autocomplete value for autosuggest forms. |
| isLoading | Boolean | false | Shows a loading spinner instead of the items if set to true. |
| showSelectedItemsInInput | Boolean | true | Defines whether or not a selected item is shown in the input after it was selected. |
| leadingInputAddons | Array of Nodes | — | Adds a list of input-addons elements in front of the input. |
| trailingInputAddons | Array of Nodes | — | Adds a list of input-addons elements after the input. |

#### Props: Additional props to be passed to the underlying ClearableInput component:

### Additional props to be passed to the underlying ClearableInput component:

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| inputProps | Object | — | Object to define properties for the input component. For the input, the ClearableInput component is used. The following props are part of the inputProps: |
| └value | String | — | The value to be set for the input. Like this the input can be controlled from the outside. |
| └onChange(deprecated) | Function | () => {} | DEPRECATED - Callback function which will be called when the input changes. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onClear | Function | () => {} | Callback function which will be called when the input is cleared. This is usually not needed as the "onSuggestionsFetchRequested" callback takes care of any input change. It is listed here for completeness and for certain edge cases. It might be removed in the future when not needed. |
| └onBlur | Function | () => {} | Callback function which gets triggered when the input looses the focus. |
| └onFocus | Function | () => {} | Callback function which gets triggered when the input gaines focus. |
| └placeholder | String | Start typing ... | String that will be displayed inside the input when nothing is typed in. Default: Start typing ... |
| └icon | String | — | Icon class name that shall be used. If defined, the input element is wrapped in an input-group and the icon will be set in an input-addon. Example: rioglyph-search |
| └disabled | Boolean | false | Boolean value that disabled the input component. |
| └hasError | Boolean | false | Boolean value that adds the class has-error to the input component. Use this for validation use cases. The Autosuggest component should be wrapped in a form-group element with the class has-feedback |
| └tabIndex | Number | 0 | The tabindex attribute allows developers to make HTML elements focusable, allow or prevent them from being sequentially focusable (usually with the Tab key, hence the name) and determine their relative ordering for sequential focus navigation. See tabIndex |
| └inputRef | Function | — | The React ref for the underlying input. |
| └className | String | — | Additional class names that are added to the input component. |