Convert Figma logo to code with AI

harvesthq logochosen

Deprecated - Chosen is a library for making long, unwieldy select boxes more friendly.

21,849
4,102
21,849
313

Top Related Projects

25,883

Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.

Selectize is the hybrid of a textbox and <select> box. It's jQuery based, and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.

Simple autocomplete pure vanilla Javascript library.

6,180

A vanilla JS customisable select box/text input plugin ⚡️

Ultra lightweight, usable, beautiful autocomplete with zero dependencies.

29,388

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.

Quick Overview

Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It adds search functionality, allows for multiple selections, and provides a more intuitive interface for users to interact with select elements in web forms.

Pros

  • Enhances usability of select elements, especially for long lists
  • Supports both single and multiple select options
  • Customizable appearance and behavior
  • Works with both jQuery and Prototype frameworks

Cons

  • No longer actively maintained (last update was in 2018)
  • May have compatibility issues with modern frameworks
  • Limited mobile support
  • Performance can degrade with very large datasets

Code Examples

  1. Basic single select:
<select class="chosen-select">
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>

<script>
  $(".chosen-select").chosen();
</script>
  1. Multiple select with placeholder:
<select data-placeholder="Choose your favorite fruits" multiple class="chosen-select">
  <option>Apple</option>
  <option>Banana</option>
  <option>Cherry</option>
  <option>Date</option>
</select>

<script>
  $(".chosen-select").chosen({
    placeholder_text_multiple: "Select your favorite fruits"
  });
</script>
  1. Disabling search threshold:
<select class="chosen-select">
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>

<script>
  $(".chosen-select").chosen({
    disable_search_threshold: 10
  });
</script>

Getting Started

  1. Include jQuery and Chosen files in your HTML:
<link rel="stylesheet" href="path/to/chosen.css">
<script src="path/to/jquery.min.js"></script>
<script src="path/to/chosen.jquery.min.js"></script>
  1. Add a select element to your HTML:
<select class="chosen-select">
  <option>Option 1</option>
  <option>Option 2</option>
  <option>Option 3</option>
</select>
  1. Initialize Chosen on your select element:
$(document).ready(function(){
  $(".chosen-select").chosen();
});

Competitor Comparisons

25,883

Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.

Pros of Select2

  • More actively maintained with frequent updates
  • Supports remote data loading and infinite scrolling
  • Better accessibility features and keyboard navigation

Cons of Select2

  • Larger file size and potentially slower performance
  • Steeper learning curve for advanced features
  • More complex configuration for some use cases

Code Comparison

Select2:

$('#select-box').select2({
  placeholder: 'Select an option',
  allowClear: true,
  ajax: {
    url: 'https://api.example.com/data'
  }
});

Chosen:

$('#select-box').chosen({
  placeholder_text_single: 'Select an option',
  allow_single_deselect: true
});

Both Select2 and Chosen are popular JavaScript libraries for enhancing HTML select elements. Select2 offers more advanced features and better maintainability, while Chosen provides a simpler, lightweight solution. Select2's code example demonstrates its ability to handle remote data loading, which is not natively supported in Chosen. However, Chosen's implementation is more straightforward for basic use cases. The choice between the two depends on project requirements, with Select2 being more suitable for complex applications and Chosen for simpler implementations.

Selectize is the hybrid of a textbox and <select> box. It's jQuery based, and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.

Pros of Selectize.js

  • More flexible and customizable, allowing for tagging, remote data loading, and custom rendering
  • Better performance with large datasets due to its virtual DOM-like approach
  • Supports creating new options on-the-fly, which Chosen doesn't offer

Cons of Selectize.js

  • Steeper learning curve due to more complex API and configuration options
  • Slightly larger file size, which may impact load times for smaller projects
  • Less widespread adoption compared to Chosen, potentially leading to fewer community resources

Code Comparison

Chosen initialization:

$('.my-select').chosen({
  placeholder_text_multiple: 'Select options'
});

Selectize.js initialization:

$('.my-select').selectize({
  placeholder: 'Select options',
  create: true,
  render: {
    option: function(item, escape) {
      return '<div>' + escape(item.text) + '</div>';
    }
  }
});

The code comparison shows that Selectize.js offers more configuration options out-of-the-box, such as the ability to create new options and custom rendering of option elements. Chosen's initialization is simpler but less flexible.

Simple autocomplete pure vanilla Javascript library.

Pros of autoComplete.js

  • Lightweight and dependency-free, resulting in faster load times
  • More flexible and customizable, allowing for advanced search patterns
  • Supports multiple data sources, including APIs and JSON

Cons of autoComplete.js

  • Less out-of-the-box styling options compared to Chosen
  • Steeper learning curve for complex implementations
  • Smaller community and fewer resources available

Code Comparison

autoComplete.js:

const autoCompleteJS = new autoComplete({
  selector: "#autoComplete",
  data: {
    src: ["Apple", "Banana", "Cherry"],
    cache: true,
  },
  resultsList: {
    element: (list, data) => {
      if (!data.results.length) {
        const message = document.createElement("div");
        message.setAttribute("class", "no_result");
        message.innerHTML = `<span>Found No Results for "${data.query}"</span>`;
        list.prepend(message);
      }
    },
    noResults: true,
  },
});

Chosen:

$(".chosen-select").chosen({
  no_results_text: "Oops, nothing found!",
  width: "95%"
});

The code comparison shows that autoComplete.js offers more granular control over the autocomplete functionality, while Chosen provides a simpler implementation with fewer configuration options. autoComplete.js allows for custom rendering of results and no-results messages, whereas Chosen relies more on pre-defined options and styling.

6,180

A vanilla JS customisable select box/text input plugin ⚡️

Pros of Choices

  • Modern JavaScript library with no jQuery dependency
  • Actively maintained with regular updates and bug fixes
  • Supports custom styling and theming options

Cons of Choices

  • Larger file size compared to Chosen
  • May have a steeper learning curve for developers familiar with Chosen
  • Some users report performance issues with large datasets

Code Comparison

Chosen:

$(".my-select").chosen({
  disable_search_threshold: 10,
  no_results_text: "Oops, nothing found!",
  width: "95%"
});

Choices:

const element = document.querySelector('.my-select');
const choices = new Choices(element, {
  searchEnabled: false,
  searchResultLimit: 10,
  noResultsText: 'Oops, nothing found!',
  width: '95%'
});

Both libraries offer similar functionality for enhancing select inputs, but Choices provides a more modern approach with vanilla JavaScript. Chosen relies on jQuery, which may be preferable for projects already using the library. Choices offers more customization options and is actively maintained, while Chosen has a smaller file size and may be easier to implement for developers familiar with jQuery-based plugins.

Ultra lightweight, usable, beautiful autocomplete with zero dependencies.

Pros of Awesomplete

  • Lightweight and dependency-free (only 2KB minified and gzipped)
  • Easily customizable with CSS and JavaScript
  • Supports keyboard navigation and accessibility features out of the box

Cons of Awesomplete

  • Limited built-in styling options compared to Chosen
  • Fewer advanced features like option grouping or multi-select
  • Smaller community and fewer extensions/plugins available

Code Comparison

Awesomplete:

new Awesomplete(input, {
  list: ["Option 1", "Option 2", "Option 3"],
  minChars: 1
});

Chosen:

$(".chosen-select").chosen({
  disable_search_threshold: 10,
  no_results_text: "Oops, nothing found!"
});

Both libraries aim to enhance select inputs, but Awesomplete focuses on simplicity and lightweight implementation, while Chosen offers more robust features and styling options. Awesomplete is ideal for projects requiring a minimal footprint and easy customization, whereas Chosen is better suited for complex use cases with extensive styling needs. The code comparison shows that Awesomplete has a more straightforward JavaScript initialization, while Chosen relies on jQuery and offers more configuration options out of the box.

29,388

Reorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.

Pros of Sortable

  • More versatile, allowing for drag-and-drop sorting of various elements
  • Actively maintained with regular updates and bug fixes
  • Supports touch devices and works well on mobile

Cons of Sortable

  • Steeper learning curve due to more complex functionality
  • May be overkill for simple select/dropdown use cases
  • Larger file size, which could impact page load times

Code Comparison

Chosen (basic implementation):

<select data-placeholder="Choose a country..." class="chosen-select" multiple>
  <option value="US">United States</option>
  <option value="UK">United Kingdom</option>
  <option value="CA">Canada</option>
</select>

Sortable (basic implementation):

<ul id="sortable">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>
<script>
  new Sortable(document.getElementById('sortable'));
</script>

Key Differences

  • Chosen focuses on enhancing select elements with search and multi-select capabilities
  • Sortable provides drag-and-drop functionality for rearranging elements
  • Chosen is primarily for form inputs, while Sortable can be used for various UI components
  • Sortable offers more customization options and events for complex interactions

Use Cases

  • Choose Chosen for improving select dropdowns and multi-select inputs
  • Opt for Sortable when you need drag-and-drop functionality or reorderable lists

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Deprecated

This version of Chosen is not currently under active development while we decide on its future direction.


Chosen

Chosen is a library for making long, unwieldy select boxes more user friendly.

  • jQuery support: 1.7+
  • Prototype support: 1.7+

For documentation, usage, and examples, see: http://harvesthq.github.io/chosen/

For downloads, see: https://github.com/harvesthq/chosen/releases/

Package managers

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.

Contributing to this project

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.

Chosen Credits

NPM DownloadsLast 30 Days