PHPackages                             gianlucagiacometti/bootstrap-select - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gianlucagiacometti/bootstrap-select

ActiveBootstrap-extension[Utility &amp; Helpers](/categories/utility)

gianlucagiacometti/bootstrap-select
===================================

Extension for the Boostrap select element

1.5.2(3y ago)491MITJavaScript

Since Jan 1Pushed 1y ago1 watchersCompare

[ Source](https://github.com/gianlucagiacometti/bootstrap-select)[ Packagist](https://packagist.org/packages/gianlucagiacometti/bootstrap-select)[ Docs](https://github.com/gianlucagiacometti/bootstrap-select/)[ RSS](/packages/gianlucagiacometti-bootstrap-select/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

bootstrap-select
================

[](#bootstrap-select)

Extension class for the Bootstrap () Select element

This program is written in plain JavaScript and is designed for Bootstrap 5.2.x and modern browsers.

The minimum version of ECMAScript is 2017. I reserve the right to switch to newer versions of ECMAScript at any time without further notice.

Although the W3C Recommendations do not mention it for HTML 5, the HTML 4.01 Recommendations () state that: "Note. Implementors are advised that future versions of HTML may extend the grouping mechanism to allow for nested groups (i.e., OPTGROUP elements may nest). This will allow authors to represent a richer hierarchy of choices." For this reason, the bsSelect class is already recursive.

The bsSelect class uses the Input and the Dropdown elements of Bootstrap, for a maximum level of compatibility.

This program is released under the MIT licence.

Requirements
------------

[](#requirements)

Bootstrap &gt;= 5.2.2

Boostrap Icons &gt;= 1.9 (used only by search and option images)

NOTE: Version numbers will follow the version numbers of Bootstrap releases (i.e. 1.**5.2.2**.1 - Bootstrap release version in bold)

Usage
-----

[](#usage)

Add these lines in the html &lt;head&gt; section:

```

```

NOTE: the values of "href" and "src" attributes must reproduce the folder structure where the two files are located.

The "selectInserted" CSS animation provides an authomatic way to create a new bsSelect class element.

You may:

1. Add to the &lt;select&gt; element the class "bootstrap-select".

    ```
     ...

    ```
2. Add the "bootstrap-select" class dynamically via JavaScript when the DOM is already loaded.

    ```
     ...

     document.querySelector("#myselect").classList.add("bootstrap-select")

    ```
3. Create a new class element manually via JavaScript without using the "bootstrap-select" class (the value of randomIndex must be a 16-digit string).

    ```
     ...

     let randomIndex = "" + Date.now() + Math.floor(Math.random()*1000)
     let mySelectElement = new bsSelect("myselect", randomIndex, classElementParameters)

     # The classElementParameters is an optional object. The default value is {}.

    ```

Options
-------

[](#options)

### Optional parameters for the Class element

[](#optional-parameters-for-the-class-element)

PropertyTypeDefaultAccepted valuesDescriptionvisibilitytextcollapsedcollapsed, expandedSets the visibility of the dropdown menu at the time of creation.### Optional classes for the &lt;select&gt; element

[](#optional-classes-for-the-select-element)

ClassDescriptionform-select-lgStyles the &lt;select&gt; element as the Bootstrap &lt;input&gt; element with the class **form-control-lg**form-select-smStyles the &lt;select&gt; element as the Bootstrap &lt;input&gt; element with the class **form-control-sm**form-select-plaintextStyles the &lt;select&gt; element as the Bootstrap &lt;input&gt; element with the class **form-control-plaintext**label-floatingStyles the &lt;select&gt; element as the Bootstrap &lt;input&gt; element with a floating label (alternative to **label-outline**.label-outlineNew style for Bootstrap &lt;input&gt; elements, which also applies to .bootstrap-select class (alternative to **label-floating**).searchableMakes the &lt;select&gt; element searchable### Optional properties for &lt;select&gt; element

[](#optional-properties-for-select-element)

PropertyTypeDefaultDescriptiondisabledbooleanfalseDisables the &lt;select&gt; element.multiplebooleanfalseCreates a multiple choice &lt;select&gt; element.### Optional attributes for the &lt;select&gt; element

[](#optional-attributes-for-the-select-element)

AttributeTypeDescriptiondata-bs-search-texttextThe **placeholder** text in the search input field. If this attribute is not used, the default **placeholder** text will be: "Search..."data-bs-toggle-buttonbooleanA toggle all checkbox shows if this attribute exists and is set to "true"### Optional properties for the &lt;option&gt; element

[](#optional-properties-for-the-option-element)

PropertyTypeDefaultDescriptiondisabledbooleanfalseDisables the &lt;option&gt; element.selectedbooleanfalseMarks the &lt;option&gt; element as selected.### Optional attributes for the &lt;option&gt; element

[](#optional-attributes-for-the-option-element)

AttributeTypeDescriptiondata-bs-select-option-icontextThe name of the Bootstrap icon which will be prepended to the text of the &lt;option&gt; element (without "bi-").data-bs-select-option-icon-classtextThe name of the class which will be added to the &lt;i&gt; element of the icon.data-bs-select-option-imagetextThe "src" attribute of the image which will be inserted at the very right of the text of the &lt;option&gt; element.data-bs-select-option-image-classtextThe name of the class which will be added to the &lt;img&gt; element of the &lt;option&gt; image.data-bs-select-option-commenttext or htmlThe content of the comment which will be inserted below the text of the &lt;option&gt; element. The comment has a default style. All additional styles must be specified in the html as classes or inline styles.data-bs-select-option-dividertextIf exists and set to "true" transforms the &lt;option&gt; element into a &lt;hr&gt; divider elementMethods
-------

[](#methods)

NameDescriptionParametersExamplesort(parameters)Sorts the options of the &lt;select&gt; element.mode: "asc" / "desc" (default: "asc")
disabled: "ignore" / "top" / "bottom" / "include" (default: "ignore")
sortDisabled: "true" / "false" (default: "true")
emptyDisabledValue: "top" / "include" (default: "top")
optionGroups: "include" / "ignore" (default: "include"){ mode: "asc" } =&gt; Sorts the option texts from A to Z.
{ mode: "desc" } =&gt; Sorts the option texts from Z to A.
{ disabled: "ignore" } =&gt; Sorts the option texts not including the disabled options.
{ disabled: "top" } =&gt; Moves all the disabled options to the top of the list.
{ disabled: "bottom" } =&gt; Moves all the disabled options to the bottom of the list.
{ disabled: "include" } =&gt; Includes all the disabled options in the sorting.
{ sortDisabled: "true" } =&gt; Sorts the disabled options according to the **mode** parameter (this parameter may be set ONLY if the parameter **disabled** is set to "top" or "bottom").
{ sortDisabled: "false" } =&gt; Does not sort the disabled options (this parameter may be set ONLY if the parameter **disabled** is set to "top" or "bottom").
{ emptyDisabledValues: "top" } =&gt; Moves all disabled options with empty value ("") to the top of the list.
{ emptyDisabledValues: "include" } =&gt; Includes all disabled options with empty value ("") in the sorting (this value of the parameter may be set ONLY if the parameter **disabled** is set to "include").
{ optionGroups: "include" } =&gt; Includes the option groups in the sorting, according to the parameter **mode** and to the text of their attribute ***label***.
{ optionGroups: "ignore" } =&gt; Keeps the position of the option groups fixed in the list and sorts the groups of options in between separately.insert(options, parent)Inserts a single &lt;option&gt; element, an array of &lt;option&gt; elements, an empty &lt;optgroup&gt; element or an array of empty &lt;optgroup&gt; elements.Acceptable **options** are both html strings or JavaScript DOM elements and their combinations:
1. '&lt;option value"myvalue"&gt;My text&lt;/option&gt;'
2. \['&lt;option value="anothervalue"&gt;Another text&lt;/option&gt;', '&lt;option value="" disabled&gt;Disabled value&lt;/option&gt;'\]
3. option (where option is an element created by: option = document.createElement("option"); option.value = "2"; option.text = "New option")
4. \[option, otherdomoptionelement\]
5. \[option, '&lt;optgroup id="my-group-id" label="My group"&gt;&lt;/optgroup&gt;'\]

The optional parameter **parent** may be:
"0" (default value) =&gt; The options will be inserted as children of the listbox.
"The attribute id of an &lt;optgroup&gt; element" =&gt; The options will be inserted as children of that &lt;optgroup&gt;.
"The random 16-dgit index of an &lt;optgroup&gt; element" =&gt; The options will be inserted as children of that &lt;optgroup&gt;.remove(parameters)Remove one or more &lt;option&gt; or &lt;optgroup&gt; elements according to the specified parameters.value: *single value*
value: *array of values*
id: *single element id*
id: *array of element ids*
index: *a single 16-digit random index of the element*value()

value(values, parameters)Gets or sets selected values.If neither values nor parameters are specified the method gets the selected value of the non-multiple &lt;select&gt; element or the array of values for the multiple &lt;select&gt; element.

Accepted values are:
1. single value for a non-multiple &lt;select&gt; element (the first element will be taken as the selected value if an array is provided)
2. a single value or an array of values for a multiple &lt;select&gt; element

Accepted parameters are:
{ swap: "true" } (default value) =&gt; The new values will be the only selected options.
{ swap: "false" } =&gt; The new values will be added to the existing selected values.
{ disabled: "false" } (default value) =&gt; Disabled options will NOT be set as selected if their value is provided.
{ disabled: "true" } =&gt; Disabled options will be set selected if their value is provided.disabled(parameters)Sets the &lt;select&gt; element as disabled or not disabled.Accepted parameters are:
"true"
"false" (default value if the parameter is omitted or is not a boolean)readonly(parameters)Sets the &lt;select&gt; element as readonly. Its effect is similar to the effect of the method **disabled** but the background of element will remain unchanged.Accepted parameters are:
"true"
"false" (default value if the parameter is omitted or is not a boolean)Further developments
--------------------

[](#further-developments)

1. Update ARIA roles and attributes

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1224d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0b87a5a9028115bee573b19f294fd618c20214889d9e2b6f947242a32a55496?d=identicon)[gianlucagiacometti](/maintainers/gianlucagiacometti)

---

Top Contributors

[![gianlucagiacometti](https://avatars.githubusercontent.com/u/52405?v=4)](https://github.com/gianlucagiacometti "gianlucagiacometti (43 commits)")[![maglnet](https://avatars.githubusercontent.com/u/4430279?v=4)](https://github.com/maglnet "maglnet (1 commits)")

---

Tags

bootstraphacktoberfestselectbootstrapselect

### Embed Badge

![Health badge](/badges/gianlucagiacometti-bootstrap-select/health.svg)

```
[![Health](https://phpackages.com/badges/gianlucagiacometti-bootstrap-select/health.svg)](https://phpackages.com/packages/gianlucagiacometti-bootstrap-select)
```

###  Alternatives

[snapappointments/bootstrap-select

The jQuery plugin that brings select elements into the 21st century with intuitive multiselection, searching, and much more. Now with Bootstrap 4 support.

9.8k480.4k3](/packages/snapappointments-bootstrap-select)[istvan-ujjmeszaros/bootstrap-duallistbox

A responsive dual listbox widget optimized for Twitter Bootstrap. It works on all modern browsers and on touch devices.

628199.4k2](/packages/istvan-ujjmeszaros-bootstrap-duallistbox)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
