🤩
Windframe Import update is finally here!

Select 2

Bootstrap 5 Select2

Bootstrap 5 Select is a component in our Contrast that displays a collapsible list of numerous values following a click. It is mostly used in forms, menus, and surveys.

Use the and arrow keys to browse between the options, and the key to choose the appropriate item with our Contrast Bootstrap 5 Select (works for stateful select).

Bootstrap Select2 Button

Give your div the class select2 to use the Contrast Bootstrap 5 Select2 Button in your project.

Bootstrap Select Button

html
html
<div class="select2">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
>
</div>

Disable Select Button

To switch off your form select, use the disabled property.

Bootstrap Select Button Disable

html
html
<div
class="select2 disabled"
>
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
</div>

Colored Select Button

Use the select2 class and add the color code for the color you want your choose choice to be. This will give your select component color.

Bootstrap Select Button Colored

html
html
<div class="select2 select2-primary">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
<div class="select2 select2-secondary">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
<div class="select2 select2-success">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
<div class="select2 select2-danger">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
<div class="select2 select2-warning">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
<div class="select2 select2-dark">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>

Colored Options with Hover

The hoverColor property adds a hover effect to your choose options.

Bootstrap Select Colored Options with Hover

html
html
<div class="select2 select2-danger hoverColor">
<div id="div">
<span class="option">
Choose Option
</span>
<i class="fa fa-angle-down"></i>
</div>
<div id="options">
<div>
<i class="fa fa-facebook"></i>
<span>Option 1</span>
</div>
<div>
<i class="fa fa-twitter"></i>
<span>Option 2</span>
</div>
<div>
<i class="fa fa-instagram"></i>
<span>Option 3</span>
</div>
<div>
<span>Option 4</span>
</div>
<div>
<span>Option 5</span>
</div>
</div>
</div>
Script
js
<script>
const select = document.querySelectorAll('.select2')
for (let i = 0; i < select.length; i++) {
const div = select[i].querySelector('#div')
const options = select[i].querySelector('#options')
div.addEventListener("click", () => {
div.classList.toggle("active")
options.classList.toggle("display")
select[i].classList.toggle("shadow")
})
const option = options.querySelectorAll('div')
for (let i = 0; i < option.length; i++) {
option[i].addEventListener("click", () => {
div.querySelector("span").innerHTML= option[i].innerHTML
console.log(option[i].innerHTML)
})
}
}
</script>

Trying to build out all user interfaces and components for your website or web app from scratch can become a very tedious task. A huge reason why we created Contrast Bootstrap to help reduce the amount of time we spend doing that, so we can focus on building some other aspects of the project. Contrast Bootstrap PRO consists of a UI Kit featuring over 10000+ component variants. Together with a template of 5 admin dashboards and 23+ additional multipurpose pages template for building almost any type of website or web app. You can view a demo and learn more about Contrast by clicking here.Download the free react template

ad-banner

Contrast Bootstrap PRO was built using the most popular CSS framework Bootstrap to help build your next landing, admin SAAS, prelaunch etc project with a clean, prebuilt and well documented template and UI components.Learn more about Contrast