1.0.2 • Published 7 months ago

olga-select v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Olga Select

A small Vanilla JavaScript library for enhanced native select elements.

Usage

1 - Download and install the library

npm i olga-select

2 - Include the library

<script src="path/to/olga-select.js"></script>

3 - Include CSS style

<link rel="stylesheet" href="path/to/olga-select.css">

4 - Use oSelect function

new OlgaSelect(document.getElementById("your_select"));

Options

Default

const options = {
  placeholder: "Select an option",
  selectedplaceholder: "selected",
  searchplaceholder: "Search",
  config: {
    updatable: false,
    sortable: false,
    searchable: false,
  },
  classes: {
    select: ["dselect"],
    dropdown: ["modal"],
    search: ["search"]
  }
};

Placeholders

AttributeDefaultDesc.
placeholder"Select an option"Placeholder for a select element with multiple attribute.
selectedplaceholder<qty> "selected"Placeholder for a select element with multiple attribute when multiple options are selected (only the "selected" string can be changed).
searchplaceholder"Search"Input element placeholder to search for options.

Searchable

You can add a seach to the select element

let options = {config: {searchable: true}}
new OlgaSelect(document.getElementById("your_select"), options);

Sortable

The list of options can be long. To find selected items easily, you can specify sortable: true

let options = {config: {sortable: true}}
new OlgaSelect(document.getElementById("your_select"), options);

Updatable

You may need to update the list of options. Use updatable

let options = {config: {updatable: true}}
new OlgaSelect(document.getElementById("your_select"), options);

Your own CSS

Olga Select doesn't want to impose a CSS style. You can therefore use your own classes.

Example with Bootstrap 5 :

const options = {
    classes: {
        select: ["form-select"],
        dropdown: ["bg-white", "border", "border-secondary"],
        search: ["form-control"]
    }
};

Full documentation : https://schmileblick.github.io/olga-select/

1.0.2

7 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.1.0

9 months ago