Live search in selectpicker of bootstrap 4

0

I am using bootstrap 4 in an application and I need to implement a search on some of the select.

This is the way the select are:

<select class="form-control selectpicker" id="mySelect1">
    <option value="0">No Selected</option>
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    <option value="3">Option 3</option>
</select>

I tried to do it with several plugins like bootstrap-select but only work with bootstrap 3 and I can not find a way to do it with bootstrap 4.

    
asked by Alan Alvarez 25.07.2017 в 20:06
source

1 answer

1

You need to include the following code in a style

/*
Make bootstrap-select work with bootstrap 4 see:
https://github.com/silviomoreto/bootstrap-select/issues/1135
*/
.dropdown-toggle.btn-default {
  color: #292b2c;
  background-color: #fff;
  border-color: #ccc;
  text-align: left;
  border: none;
  border-bottom: 1px solid #303f9f;
  border-radius: 0px;
}
.dropdown-toggle.btn-default:focus,
.dropdown-toggle.btn-default:hover{
  color: #292b2c;
  background-color: #fff;
  border-color: #ccc;
  text-align: left;
  border: none;
  border-bottom: 2px solid #303f9f;
  border-radius: 0px;
}
.bootstrap-select.show>.dropdown-menu>.dropdown-menu {
  display: block;
}

.bootstrap-select > .dropdown-menu > .dropdown-menu li.hidden{
  display:none;
}

.bootstrap-select > .dropdown-menu > .dropdown-menu li a{
  display: block;
  width: 100%;
  padding: 3px 1.5rem;
  clear: both;
  font-weight: 400;
  color: #292b2c;
  text-align: inherit;
  white-space: nowrap;
  background: 0 0;
  border: 0;
}

.dropdown-menu > li.active > a {
  color: #fff !important;
  background-color: #3f51b5 !important;
}

.bootstrap-select .check-mark::after {
  content: "✓";
}
.bootstrap-select button {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Make filled out selects be the same size as empty selects */
.bootstrap-select.btn-group .dropdown-toggle .filter-option {
  display: inline !important;
}
    
answered by 22.08.2017 в 21:40