Back



This example shows a single-select autocomplete with a clear icon inside the input field.
Single-select (Icon)

Source of exampleCopy to clipboard


const userAutocomplete = new AvalynxAutocomplete('#userSearch', {
    fetchData: async (query) => {
        const response = await fetch('php/result.php?type=users&search=' + encodeURIComponent(query));
        return await response.json();
    },
    clearStyle: 'icon',
    onChange: (key, value) => console.log('User:', key, value)
}, {
    placeholder: 'Search user...',
    noResults: 'No users found'
});
	
AvalynxAutocomplete on GitHub Avalynx on GitHub