Skip to main content

Classes and Styles

CSS Classes used in npm-autocomplete-plugin html template

This is for informational purpose only. Be cautious if you are overriding these CSS as it may affect dropdown style if updated incorrectly.

ClassesDescriptionComments
auto-complete-textfield-containerClass of parent html div templateAble to override through parentContainerClass or parentContainerStyle
label-containerClass of label tagAble to override through inputLabelContainerClass or inputLabelContainerStyle
label-valueClass of <label> tagAble to override through inputLabelClass or inputLabelStyle
field-containerClass of div that surrounds input field and autocomplete liAble to override through inputFieldContainerClass or inputFieldContainerStyle
auto-complete-textfieldClass of input text fieldAble to override through inputFieldClass or inputFieldStyle
auto-complete-listClass of div that surrounds liAble to override through listContainerClass or listContainerStyle
unorder-listClass of ulAble to override through dropdownUnorderedListClass or dropdownUnorderedListStyle
autocomplete-data-listClass of liAble to override through disableListClass or dropdownListStyle
autocomplete-data-list noSearchResultClass of li if search result not found.Able to override through noResultClass or noResultStyle

Adding Custom CSS Class to autocomplete

Import CustomClassType from the module (Optional).

CustomClassTypesRequiredDescription
parentContainerClassNoAdds class to div surrounding the input field and dropdown list.
inputFieldContainerClassNoAdds class to the parent div of input field
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.
disableListClassNoAdds class to each li items. Depends on disableListFn function or disableProperty
inputLabelClassNoAdds class to <label> field
inputLabelContainerClassNoAdds class to parent div of <label> field
viewMoreClassNoAdds class to View More li item

You can import CustomClassType Type into your app, to see the custom class types available. Its optional, but would be good to use. Write your custom class in global css file or use ::ng-deep from specific components.

import { CustomClassType } from 'ng-autocomplete-plugin';

In your template, do the following:

customClassType: CustomClassType = {
inputFieldClass: 'class1',
dropdownListClass: 'class1 class2'
}
<ng-autocomplete
[dropdownData]="YOUR_DROPDOWN_DATA"
(emitSelectedValue)="YOUR_CUSTOM_FUNTION($event)"
[objectProperty]="'name'"
[customClassType]="customClassType">
</ng-autocomplete>

Adding Custom NgStyle to autocomplete

Import CustomNgStyleType from the module (Optional).

CustomNgStyleTypesRequiredDescription
parentContainerStyleNoAdds style to div surrounding the input field and dropdown list.
inputFieldContainerStyleNoAdds style to the parent div of input field
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 parent div of <label> field
viewMoreStyleNoAdds style to View More li item.

You can import CustomNgStyleType Type into your app, to see the custom class types available. Its optional, but would be good to use.

import { CustomNgStyleType } from 'ng-autocomplete-plugin';

In your template, do the following:

customClassType: CustomNgStyleType = {
inputFieldStyle: {color: '#FFFFFF' },
dropdownListStyle: {padding: 2px }
}
<ng-autocomplete
[dropdownData]="YOUR_DROPDOWN_DATA"
(emitSelectedValue)="YOUR_CUSTOM_FUNTION($event)"
[objectProperty]="'name'"
[customClassType]="customClassType">
</ng-autocomplete>