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>

A range of options enable Bootstrap Select Dropdown to be configured to suit a wider range of use cases.

<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({
      'maxListLength': 0,
      'badges': true,
      'tooltips' : 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>

In this example, the following options have been set.

  • maxListLength is set to 0 to ensure the button is populated with the %count_selected% selected for any number of selections.
  • badges offer enhanced visual feedback for longer, more complex lists or lists where a large selection is expected.
  • Icons are used in this example. Bootstrap does not ship with an icon framework by default, so some integration may be required. In this example, SCSS/CSS has been applied to make SVG icons work (height, width, fill) within buttons and badges.
  • tooltips clarify the functionality of each button, tooltips are added to the 'Clear search', 'Deselect all' and 'Select all' buttons. This enhances the default title attribute.

For a full list of options, consult the options documentation.