How to use
NPM
npm install vanilla-select --save-dev
Bower
bower install vanilla-select --save-dev
Example
<!-- html -->
<div ref="select-box"></div>
// javascript
const source = [{
icon: 'fa-font',
value: 'Amatic SC'
}];
const select = new Select({
placeholder: 'Select Font',
dataset: source,
search: true,
noResults: 'No results found',
onSelected: item => callback(item)
}).componentMount({
el: document.querySelector('[ref="select-box"]')
});
Demo
Or if you want to set default selected item:
const select = new Select({
dataset: source,
selected: 'Allura',
onSelected: item => callback(item)
}).componentMount({
el: document.querySelector('[ref="select-box"]')
});
Contributions
Any feedback on issues or compatibility problems is greatly appreciated, please leave it at my github page