chosen-js, react-select, and select2 are libraries used to enhance standard HTML select elements with search, tagging, and styling capabilities. react-select is built specifically for React applications using components and props. select2 and chosen-js are legacy jQuery plugins that manipulate the DOM directly and depend on jQuery. Choosing the right tool depends heavily on your framework β React projects should avoid jQuery dependencies.
These three libraries solve the same problem β making HTML select boxes more powerful β but they approach it from different eras of web development. react-select is built for modern component frameworks, while select2 and chosen-js belong to the jQuery era. Understanding their architectural differences is critical for maintaining stable applications.
react-select is a pure React component.
// react-select: Native React component
import Select from 'react-select';
const MyComponent = () => (
<Select options={options} />
);
select2 requires jQuery.
// select2: jQuery initialization
import $ from 'jquery';
import 'select2';
$('#my-select').select2({
data: options
});
chosen-js also requires jQuery.
// chosen-js: jQuery initialization
import $ from 'jquery';
import 'chosen-js';
$('.chosen-select').chosen();
react-select accepts data as a prop.
// react-select: Props-based data
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' }
];
<Select options={options} />
select2 accepts data via configuration or DOM.
<option> tags.// select2: Config-based data
$('#my-select').select2({
data: [
{ id: 'chocolate', text: 'Chocolate' },
{ id: 'strawberry', text: 'Strawberry' }
]
});
chosen-js relies on existing DOM elements.
<option> tags already present in the HTML.// chosen-js: DOM-based data
// HTML: <select class="chosen-select"><option>Chocolate</option></select>
$('.chosen-select').chosen();
// To update: modify DOM then trigger
$('.chosen-select').trigger('chosen:updated');
react-select uses React components for customization.
Option or Control with your own components.// react-select: Custom components
const CustomOption = (props) => (
<components.Option {...props}>
<strong>{props.label}</strong>
</components.Option>
);
<Select components={{ Option: CustomOption }} />
select2 uses templates and CSS.
// select2: Template customization
$('#my-select').select2({
templateResult: (data) => `<strong>${data.text}</strong>`
});
chosen-js uses CSS classes and limited config.
// chosen-js: CSS customization
// HTML: <select class="chosen-select custom-class"></select>
$('.chosen-select').chosen();
// CSS: .custom-class .chosen-single { background: red; }
react-select uses React props for events.
onChange are passed as standard props.// react-select: React events
const handleChange = (selected) => {
console.log(selected.value);
};
<Select onChange={handleChange} />
select2 uses jQuery events.
select2:select on the element.// select2: jQuery events
$('#my-select').on('select2:select', (e) => {
console.log(e.params.data);
});
chosen-js uses jQuery events.
chosen:change on the element.// chosen-js: jQuery events
$('.chosen-select').on('chosen:change', (evt, params) => {
console.log(params.selected);
});
| Feature | react-select | select2 | chosen-js |
|---|---|---|---|
| Framework | βοΈ React | π§© jQuery | π§© jQuery |
| Data Input | π₯ Props (Array) | π₯ Config or DOM | π₯ DOM Only |
| Updates | π Automatic (React State) | π οΈ Manual (jQuery) | π οΈ Manual (DOM Trigger) |
| Customization | π¨ React Components | π¨ Templates | π¨ CSS Only |
| Events | β‘ React Props | β‘ jQuery Events | β‘ jQuery Events |
| Modern Stack | β Yes | β No | β No |
react-select is the clear choice for modern React development β it respects the component model and avoids external dependencies. It handles state, updates, and styling in ways that feel natural to React developers.
select2 and chosen-js are legacy tools β they belong to the jQuery era of web development. While still functional for older projects, they introduce friction in modern stacks due to DOM manipulation and jQuery requirements.
Final Thought: If you are building with React, stick to react-select. If you are maintaining an old jQuery site, select2 offers more features than chosen-js, but both should be replaced when migrating to modern frameworks.
Choose this only for legacy projects where the original Chosen library is already in use and needs a maintained fork. It is lighter than Select2 but still relies on jQuery and direct DOM changes. Avoid this for modern component-based architectures.
Choose this for any new React application. It integrates cleanly with React's lifecycle, supports server-side rendering, and avoids jQuery conflicts. It offers strong TypeScript support and customizable components without direct DOM manipulation.
Choose this only if you are maintaining a legacy jQuery application that requires rich dropdown features. Do not use this in new React projects because it conflicts with React's virtual DOM and requires jQuery. It is best suited for older server-rendered pages using jQuery.
Chosen is a library for making long, unwieldy select boxes more user friendly.
For documentation, usage, and examples, see: http://harvesthq.github.io/chosen/
For downloads, see: https://github.com/harvesthq/chosen/releases/
Chosen is available through Bower, npm, and Composer, however, the package names are not the same.
To install with Bower:
bower install chosen
To install with npm:
npm install chosen-js
To install with Composer:
composer require harvesthq/chosen
The compiled files for these packages are automatically generated and stored in a 2nd Chosen repository. No pull requests will be accepted to that repository.
We welcome all to participate in making Chosen the best software it can be. The repository is maintained by only a few people, but has accepted contributions from over 50 authors after reviewing hundreds of pull requests related to thousands of issues. You can help reduce the maintainers' workload (and increase your chance of having an accepted contribution to Chosen) by following the guidelines for contributing.