Home

Awesome

A Select2 v4 Theme for Bootstrap 3
select2-bootstrap-theme version License

Demonstrations available at select2.github.io/select2-bootstrap-theme

Compatibility

Built and tested with Bootstrap v3.3.7 and Select2 v4.0.3 in latest Chrome, Firefox and Safari (Mac) and Internet Explorer 11, 10 and 9 (should work in IE8).

Installation

You can download select2-bootstrap-theme from this GitHub repo, install it using Bower or npm – required if you want to integrate the Sass or Less sources in your build process – or source the compiled CSS directly from CDNJS or jsDelivr.

Install using Bower or npm/yarn

You may install select2-bootstrap-theme with Bower, npm or Yarn:

// Bower
bower install select2-bootstrap-theme

// npm
npm install select2-bootstrap-theme

// yarn
yarn add select2-bootstrap-theme
Source select2-bootstrap-theme from CDNJS or jsDelivr

select2-bootstrap-theme is also available on CDNJS and jsDelivr.

Usage

select2-bootstrap-theme only works with Select2 v4.x. Applying the theme requires select2-bootstrap.css referenced after the default select2.css that comes with Select2:

<link rel="stylesheet" href="select2.css">
<link rel="stylesheet" href="select2-bootstrap.css">

To apply the theme, tell Select2 to do so by passing bootstrap to the theme option when initializing Select2:

$( "#dropdown" ).select2({
    theme: "bootstrap"
});

You may also set it as the default theme for all Select2 widgets like so:

$.fn.select2.defaults.set( "theme", "bootstrap" );

Changelog

0.1.0-beta.10
0.1.0-beta.9
0.1.0-beta.8
0.1.0-beta.7
0.1.0-beta.6
0.1.0-beta.5
0.1.0-beta.4
0.1.0-beta.3
0.1.0-beta.2
0.1.0-beta.1

Contributing

The project offers Less and Sass sources for building select2-bootstrap.css; both make use of variables from either Bootstrap (Less) or Bootstrap for Sass. The demo pages are built using Jekyll and there are a bunch of Grunt tasks to ease development.

With Jekyll, node.js and Less installed, run

npm install

to install all necessary development dependencies (Sass is compiled vLibSass/node-sass).

Develop in src/select2-bootstrap.scss and test your changes using grunt serve. Ideally, port your changes to lib/select2-bootstrap.less and make sure tests are passing to verify that both Less and Sass compile down to the target CSS via npm test.

grunt scss2less helps in converting the Sass source to its Less counterpart (and overwrites the existing src/select2-bootstrap.less), but doesn't do the full job – please review the changes to the Less source file and make the necessary adjustments.

Copyright and license

The license is available within the repository in the LICENSE file.