Skip to main content

Classes and Styles

Adding Custom CSS Class to autocomplete

Please note that, if you are using JSX template, you may not be able to import the type CustomClassType. However you can refer this documentation and pass the custom classes without importing type.

Import CustomClassType from the module (Optional).

import { CustomClassType } from 'react-autocomplete-plugin';
CustomClassTypesRequiredDescription
parentContainerClassNoAdds class to parent div surrounding the input field and dropdown list.
inputFieldClassNoAdds class to input textfield
listContainerClassNoAdds class to div that surrounds ul of dropdown list.
dropdownUnorderedListClassNoAdds class to ul of dropdown list.
dropdownListClassNoAdds class to each li items
noResultClassNoAdds class to separate li item to show no result message.
inputLabelClassNoAdds class to <label> field
inputLabelContainerClassNoAdds class to surrounding div of input label.
customSpinnerClassNoAdds class to span to show customized spinner.
viewMoreClassNoAdds class to View More li item
customClassType: CustomClassType = {
inputFieldClass: 'class1',
dropdownListClass: 'class1 class2'
}
<Autocomplete
dropdownData="YOUR_DROPDOWN_DATA"
broadcastSelectedValue="YOUR_CUSTOM_FUNTION($event)"
objectProperty="'name'"
customClassType="customClassType">
</Autocomplete>

Adding Custom CSS styles to autocomplete

Please note that, if you are using JSX template, you may not be able to import the type CustomStyleType. However you can refer this documentation and pass the custom styles without importing type.

Import CustomStyleType from the module (Optional).

import { CustomStyleType } from 'react-autocomplete-plugin';
CustomStyleTypesRequiredDescription
parentContainerStyleNoAdds style to div surrounding the input field and dropdown list.
inputFieldStyleNoAdds style to input textfield
listContainerStyleNoAdds style to div that surrounds ul of dropdown list.
dropdownUnorderedListStyleNoAdds style to ul of dropdown list.
dropdownListStyleNoAdds style to each li items
noResultStyleNoAdds style to separate li item to show no result message.
inputLabelStyleNoAdds style to <label> field
inputLabelContainerStyleNoAdds style to surrounding div of input label.
customSpinnerStyleNoAdds style to span to style the customized spinner.
viewMoreStyleNoAdds style to View More li item.
customStyle: CustomStyleType = {
inputFieldStyle: {color: '#FFFFFF' },
dropdownListStyle: {padding: 2px }
}
<Autocomplete
dropdownData="YOUR_DROPDOWN_DATA"
broadcastSelectedValue="YOUR_CUSTOM_FUNTION($event)"
objectProperty="'name'"
customStyle="customStyle">
</Autocomplete>

For inspecting the classes or styles during develeopment, pass inspectAutoCompleteList as true so that the dropdown list will not close which will help to inspect the list. But don't forget to remove or make it false during production deployment