To use interactive chips (where users can type tags, use autocomplete, or delete chips), initialize the M.Chips plugin on one or more elements with the .chips class.
Note on Data Format: In version 2.0.0+, the data option must follow the Chip data object structure (see Chip data object).
document.addEventListener('DOMContentLoaded', function() {
const elems = document.querySelectorAll('.chips');
const instances = M.Chips.init(elems, {
// specify options here
autocompleteOptions: {
data: [
{id: 12, text: "Apple"},
{id: 13, text: "Microsoft"},
{id: 42, text: "Google", image: 'http://placehold.it/250x250'}
]
},
placeholder: 'Enter a tag',
secondaryPlaceholder: '+Tag',
});
});