Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vanilla-select

Package Overview
Dependencies
Maintainers
4
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-select

Standalone replacement for select boxes

  • 1.0.25
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

vanilla-select npm version

A vanilla, lightweight (~2.5kb gzipped), configurable select box component.

Demo Page

Advantages

  • Lightweight
  • No Dependencies
  • Elegant API - inspiration taken from React.Component
  • Fast search

Installation

With NPM:

npm install vanilla-select --save-dev

With Bower:

bower install vanilla-select --save-dev

Or include directly:

<!-- Include CSS -->
<link rel="stylesheet" href="dist/vanilla-select.min.css">
<!-- Include JavaScript -->
<script src="/dist/vanilla-select.min.js"></script>

Setup

  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"]')
        });

Configuration

OptionDefinition
placeholderType: String
Default: ''
Placeholder text
datasetType: Array
Default: []
Equivelant to the element within a select
searchType: Boolean
Default: false
Whether a user should be allowed to search
noResultsType: String
Default: ''
The text that is shown when search has returned no results
selectedType: Object
Default: null
Default selected option
onSelectedArguments: item
Callback, invoked each time the item is selected, regardless if it changes the value

Development

To setup a local environment: clone this repo, navigate into it's directory in a terminal window and run the following command:

npm install

Browser compatibility

vanilla-select is compiled using Closure Compiler to enable support for ES5 browsers.

Browsers

Edge 15+ Chrome 41+ FireFox 35+ Opera 28+ Safari 9+

If you need to support IE11 and IE Edge14 - use vanilla-select-ie.min.js bundle. It includes element-closest polyfill.

Gulp tasks

TaskUsage
gulp buildBuild JS an CSS
gulp serveFire up local server for development

Roadmap

  • Keyboard navigation

License

MIT License

Keywords

FAQs

Package last updated on 30 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc