Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
/ nice-select2 Public archive
forked from bluzky/nice-select2

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns

License

Notifications You must be signed in to change notification settings

marcfowler/nice-select2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nice Select

A lightweight Vanilla JavaScript plugin that replaces native select elements with customizable dropdowns.

Install

npm i nice-select2

Usage

Include nice-select2 script.

<script src="path/to/nice-select2.js"></script>

Include the styles, either the compiled CSS...

<link rel="stylesheet" href="path/to/nice-select2.css" />

Or import nice-select2 using ES6 syntax

import NiceSelect from "nice-select2";
@import "~nice-select2/dist/css/nice-select2.css";
// or
@import "~nice-select2/src/scss/nice-select2.scss";

Finally, initialize the plugin.

Using the minimified file directly:

NiceSelect.bind(document.getElementById("a-select"), {searchable: true});

Using as import in webpack:

new NiceSelect(document.getElementById("a-select"), {searchable: true});

Instance method

  • update() : update nice-select items to match with source select
  • focus(): open dropdown list and focus on the search box if search is enabled
  • disable(): disable select
  • enable(): enable select
  • destroy(): destroy NiceSelect2 instance
  • clear(): clear all selected options

Full documentation and examples at https://bluzky.github.io/nice-select2/.

About

A lightweight vanilla javascript library that replaces native select elements with customizable dropdowns

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 56.7%
  • SCSS 43.3%