All Projects → BMSVieira → BVSelect-VanillaJS

BMSVieira / BVSelect-VanillaJS

Licence: MIT license
BVSelect - Vanilla Javascript Fully Customizable SelectBox

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to BVSelect-VanillaJS

bs-breakpoints
A plugin which detect Bootstrap 4 breakpoints and emit when there is a change
Stars: ✭ 22 (-79.44%)
Mutual labels:  vanilla-javascript, vanillajs
Moovie.js
Movie focused HTML5 Player
Stars: ✭ 293 (+173.83%)
Mutual labels:  vanilla-javascript, vanillajs
vanillajs-hello
Start a VanillaJS website using WebPack in just 30 seconds: HTML,CSS,Babel,SASS,Bootstrap,Prettier,Gitpod
Stars: ✭ 24 (-77.57%)
Mutual labels:  vanilla-javascript, vanillajs
Bs Stepper
A stepper for Bootstrap 4.x
Stars: ✭ 261 (+143.93%)
Mutual labels:  vanilla-javascript, vanillajs
Vanillajs Deck
A Vanilla.js Single Page App (SPA) slide deck for a presentation about Vanilla.js written with no frameworks.
Stars: ✭ 119 (+11.21%)
Mutual labels:  vanilla-javascript, vanillajs
tensorflowjs-remove-background
Remove Background from the picture using WebAssembly & TensorFlow.js
Stars: ✭ 79 (-26.17%)
Mutual labels:  vanilla-javascript, vanillajs
Autocomplete.js
Simple autocomplete pure vanilla Javascript library.
Stars: ✭ 3,428 (+3103.74%)
Mutual labels:  vanilla-javascript, customizable
svelte-googlemaps
Svelte Google Maps Components
Stars: ✭ 62 (-42.06%)
Mutual labels:  vanilla-javascript, vanillajs
Html5sortable
VanillaJS sortable lists and grids using native HTML5 drag and drop API.
Stars: ✭ 1,384 (+1193.46%)
Mutual labels:  vanilla-javascript, vanillajs
Vanilla Ui Router
Simple vanilla JavaScript router
Stars: ✭ 42 (-60.75%)
Mutual labels:  vanilla-javascript, vanillajs
Learn Vanilla Js
Open source list of paid & free resources to learn vanilla JavaScript
Stars: ✭ 945 (+783.18%)
Mutual labels:  vanilla-javascript, vanillajs
Datepickk
Simple, beautiful and powerful datepicker!
Stars: ✭ 160 (+49.53%)
Mutual labels:  vanilla-javascript, vanillajs
Sharer.js
🔛 🔖 Create your own social share buttons. No jquery.
Stars: ✭ 1,624 (+1417.76%)
Mutual labels:  vanilla-javascript, vanillajs
Bs Custom File Input
A little plugin for Bootstrap 4 custom file input
Stars: ✭ 162 (+51.4%)
Mutual labels:  vanilla-javascript, vanillajs
Baguettebox.js
⚡ Simple and easy to use lightbox script written in pure JavaScript
Stars: ✭ 2,252 (+2004.67%)
Mutual labels:  vanilla-javascript
js-plugin-starter-kit
VanillaJS (pure JavaScript) plugin starter with Webpack 4 and Babel 7.
Stars: ✭ 100 (-6.54%)
Mutual labels:  vanilla-javascript
Long Press Event
Adds `long-press` event to the DOM in 1k of pure JavaScript
Stars: ✭ 187 (+74.77%)
Mutual labels:  vanilla-javascript
Lind
Lind is an open source that allows to create any kind of AB test on your site.
Stars: ✭ 183 (+71.03%)
Mutual labels:  vanilla-javascript
Butterfly
🎨 Powerful, minimalistic, cross-platform, opensource note-taking app
Stars: ✭ 381 (+256.07%)
Mutual labels:  customizable
symfony-hybrid-flex-port
A port of the Hybrid application to Symfony Flex
Stars: ✭ 28 (-73.83%)
Mutual labels:  vanilla-javascript

BVSelect - Vanilla JS


Replaces native select elements with fully customizable dropdowns.

Demo:

https://bmsvieira.github.io/BVSelect-VanillaJS/

Features:

  • 🔧 Fully Customizable
  • 💪 No Dependencies, built with VanillaJS
  • 🌎 Tested in All Modern Browsers
  • 😎 Images & FontIcons
  • ⌨️ Mobile Optimization & Normal Usage
  • 🔎 Built-in Searchbox
  • 🖥 Prevented Viewport Overflow

Installation:

1 - Include JavaScript Source.

<script src="path/to/bvselect.js"></script>

2 - Include Styles.

<link rel="stylesheet" href="path/to/bvselect.css">

4 - Set HTML.

<select id="selectbox">
  <option data-separator="true"> Select Option </option>
  <option value="1"> Option 1 </option>
  <option value="2"> Option 2 </option>
  <option value="3" disabled> Option 3 </option>
  <option value="4"> Option 4 </option>
</select>

3 - Initilize.

document.addEventListener("DOMContentLoaded", function() {
      var demo1 = new BVSelect({
        selector: "#selectbox",
        width: "100%",
        searchbox: true,
        offset: true,
        placeholder: "Select Option",
        search_placeholder: "Search...",
        search_autofocus: true,
        breakpoint: 450
      });
});

Polyfill:

BVSelect uses ES6 which isn't supported in all browsers yet (especially older browsers). Some features will need to be polyfilled to be available. Use the following sources instead:

// Polyfill Source
<script src="https://polyfill.io/v3/polyfill.min.js?features=document.querySelector%2Cdocument%2CArray.prototype.forEach%2CNodeList.prototype.forEach%2CElement.prototype.closest%2CArray.from%2Ces5"></script>

// BVSelect Polyfilled Version
<script src="path/to/bvselect.polyfill.js"></script>

Methods:

Destroy: Removes dropdown, unbinds all its events and brings back the original Select.

demo1.Destroy();

Update: Updates current dropdown based on changes to the original selectbox.

demo1.Update();

Get ID: Returns the ID that was generated to build dropdown, so you can add custom classes.

demo1.GetID();

Set Option: Set new selected option.

Name Value Description
type byIndex or byValue Parameter
value string Value to search
demo1.SetOption({
  type: "byIndex",
  value: "1"
});

Change: Changes dropdown's settings

Name Value Description
placeholder string Modify dropdown's placeholder
search_placeholder string Modify input's placelholder
options object Replaces all options in the original selectbox
demo1.Change({
  placeholder: "New Placeholder",
  search_placeholder: "New Searchbox's Placeholder",
  options : {
          0: {
              inner_text: 'Metallica',
              value: "met",
              disabled: false,
              separator: false,
              img: "https://img.icons8.com/color/2x/usa.png",
              icon: "fa fa-hashtag"
          },
          1: {
              inner_text: 'Megadeth',
              value: "meg",
              disabled: false,
              separator: false,
              img: false,
              icon: "fa fa-tshirt"
          },
          2: {
              inner_text: 'Slayer',
              value: "sla",
              disabled: false,
              separator: false,
              img: false,
              icon: "fa fa-hashtag"
          }  
    }
});

// Update Dropdown based on changes to the original selectbox
demo1.Update();

Append Option: Add new options to existing selectbox

Name Value Description
position afterbegin or beforeend Add new options at beginning or ending of the dropdown
options object Options to add to original selectbox
demo1.AppendOption({
    position: "beforeend",
    options : {
            0: {
                inner_text: 'Metallica',
                value: "met",
                disabled: false,
                separator: false,
                img: "https://img.icons8.com/color/2x/usa.png",
                icon: "fa fa-hashtag"
            },
            1: {
                inner_text: 'Megadeth',
                value: "meg",
                disabled: false,
                separator: false,
                img: false,
                icon: "fa fa-tshirt"
            }
      }
  });

// Update Dropdown based on changes to the original selectbox
demo1.Update();

Settings:

Name Value Default Description
selector ID --- Specify ID of the element
width px or % 100% Specify the width of the main element
searchbox boolean false Add a search box to the list
offset boolean true Fixes Viewport Offset
placeholder string Select Option Modify dropdown's placeholder
search_placeholder string Search... Modify input's placelholder
search_autofocus boolean false Automatically focus on search input if enabled
breakpoint integer 600 Defines the responsive breakpoint (in px)
document.addEventListener("DOMContentLoaded", function() {
      var demo1 = new BVSelect({
        selector: "#selectbox",
        searchbox: true,
        offset: true
      });
});

Attributes:

Name Value Description
data-separator boolean Highlights an option
data-img Image Source Adds an Image to option
data-icon fa fa-hashtag Adds an FontIcon to option, can be used any provider as long it is identical. Images will be prioritized over icons.
disabled (native) disabled Disables an option

To add FontIcons, you must include it's own sources

<select id="selectbox">
    <option value="##" data-separator="true" selected>Select Option</option>
    <option data-img="path/to/img.png" value="--">Cristiano Ronaldo</option>
    <option data-icon="fa fa-hashtag" value="--" >Lionel Messi </option>
    <option data-img="path/to/img.png" value="--" disabled>Neymar Jr. (Disabled)</option>
    <option data-img="path/to/img.png" value="--">Ronaldinho</option>
    <option data-img="path/to/img.png" value="--">Luis Figo</option>
</select>

All CSS styles are fully customizable in order to match your style

Appearance

This was built to fit any style and to be 100% fully customizable, so you are able to change everything in the css file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].