A jQuery plugin for Bootstrap 4 that converts <select> and <select multiselect> elements to dropdowns. Uses Bootstrap's dropdown plugin and fuse.js for fuzzy search.

Use Bootstrap Select Dropdown to improve the user experience for long option lists. Compared to a regular multiselect, this plugin adds:

  • a search box;
  • keyboard navigation for search; and
  • select/deselect all controls.

<div class="form-group">
  <label for="demo_overview">Select one or more countries</label>
    <select id="demo_overview" class="form-control" data-role="select-dropdown" multiple>
    <!-- options -->
  </select>
</div>

For lists where it is likely a large collection of items will be selected, better visual feedback can be achieved by enabling badges.

Icons are used in this example. Bootstrap does not ship with an icon framework by default, so some integration may be required to get this to work. In this example, SCSS/CSS has been applied to make SVG icons work (height, width, fill) within buttons and badges.

<div class="form-group">
  <label for="demo_overview_icons_badges">Select one or more countries</label>
  <select id="demo_overview_example" class="form-control" multiple>
    <!-- options -->
  </select>
</div>

<script>
  $(document).ready(function(){
    $("#demo_multiselect").selectDropdown({
      'badges': true,
      'htmlBtnClear': '<svg class="ion"><use xlink:href="#ion-close"></use></svg>',
      'htmlBtnDeselectAll': '<svg class="ion"><use xlink:href="#ion-close-circled"></use></svg>',
      'htmlBtnSelectAll': '<svg class="ion"><use xlink:href="#ion-checkmark-circled"></use></svg>',
      'htmlBtnBadgeRemove': '<svg class="ion"><use xlink:href="#ion-close"></use></svg>'
    });
  });
</script>