by Jerad Bitner

Module Monday: Chosen

For a long time now, Drupal has been using the idea of the "auto-complete" for such things as taxonomy tags, node references, and user references. While convenient in the fact that it's ajaxified and will display relevant options as you begin to type, it's long been a bit of a problem for users who really have no pre-conceived notion of how typical auto-complete form controls work, or for those with slower connections who end up waiting while they stare at a little spinning icon for their results to be returned to them.

Select boxes are a universally recognized form control, and also a valid alternative to each of the field types I described above which typically utilize the auto-complete widget within Drupal. However, for many use cases, the typical select box widget can have a ton of results and become a very long list of options to scroll down through and chose from.

The auto-complete widget was originally created in an attempt to mitigate this UX problem. But I submit to you an attractive alternative to the typical solution this problem: Chosen.

Chosen is a javascript library built by the incredible people who brought you the time tracking software, Harvest. The library is an open-source project on Github and simply seeks to "... [make] long, unwieldy select boxes more user friendly." It can take your typical select box from this:

United StatesUnited KingdomAfghanistanAlbaniaAlgeriaAmerican SamoaAndorraAngolaAnguillaAntarcticaAntigua and BarbudaArgentinaArmeniaArubaAustraliaAustriaAzerbaijanBahamasBahrainBangladeshBarbadosBelarusBelgiumBelizeBeninBermudaBhutanBoliviaBosnia and HerzegovinaBotswanaBouvet IslandBrazilBritish Indian Ocean TerritoryBrunei DarussalamBulgariaBurkina FasoBurundiCambodiaCameroonCanadaCape VerdeCayman IslandsCentral African RepublicChadChileChinaChristmas IslandCocos (Keeling) IslandsColombiaComorosCongoCongo, The Democratic Republic of TheCook IslandsCosta RicaCote D'ivoireCroatiaCubaCyprusCzech RepublicDenmarkDjiboutiDominicaDominican RepublicEcuadorEgyptEl SalvadorEquatorial GuineaEritreaEstoniaEthiopiaFalkland Islands (Malvinas)Faroe IslandsFijiFinlandFranceFrench GuianaFrench PolynesiaFrench Southern TerritoriesGabonGambiaGeorgiaGermanyGhanaGibraltarGreeceGreenlandGrenadaGuadeloupeGuamGuatemalaGuineaGuinea-bissauGuyanaHaitiHeard Island and Mcdonald IslandsHoly See (Vatican City State)HondurasHong KongHungaryIcelandIndiaIndonesiaIran, Islamic Republic ofIraqIrelandIsraelItalyJamaicaJapanJordanKazakhstanKenyaKiribatiKorea, Democratic People's Republic ofKorea, Republic ofKuwaitKyrgyzstanLao People's Democratic RepublicLatviaLebanonLesothoLiberiaLibyan Arab JamahiriyaLiechtensteinLithuaniaLuxembourgMacaoMacedonia, The Former Yugoslav Republic ofMadagascarMalawiMalaysiaMaldivesMaliMaltaMarshall IslandsMartiniqueMauritaniaMauritiusMayotteMexicoMicronesia, Federated States ofMoldova, Republic ofMonacoMongoliaMontenegroMontserratMoroccoMozambiqueMyanmarNamibiaNauruNepalNetherlandsNetherlands AntillesNew CaledoniaNew ZealandNicaraguaNigerNigeriaNiueNorfolk IslandNorthern Mariana IslandsNorwayOmanPakistanPalauPalestinian Territory, OccupiedPanamaPapua New GuineaParaguayPeruPhilippinesPitcairnPolandPortugalPuerto RicoQatarReunionRomaniaRussian FederationRwandaSaint HelenaSaint Kitts and NevisSaint LuciaSaint Pierre and MiquelonSaint Vincent and The GrenadinesSamoaSan MarinoSao Tome and PrincipeSaudi ArabiaSenegalSerbiaSeychellesSierra LeoneSingaporeSlovakiaSloveniaSolomon IslandsSomaliaSouth AfricaSouth Georgia and The South Sandwich IslandsSouth SudanSpainSri LankaSudanSurinameSvalbard and Jan MayenSwazilandSwedenSwitzerlandSyrian Arab RepublicTaiwan, Republic of ChinaTajikistanTanzania, United Republic ofThailandTimor-lesteTogoTokelauTongaTrinidad and TobagoTunisiaTurkeyTurkmenistanTurks and Caicos IslandsTuvaluUgandaUkraineUnited Arab EmiratesUnited KingdomUnited StatesUnited States Minor Outlying IslandsUruguayUzbekistanVanuatuVenezuelaViet NamVirgin Islands, BritishVirgin Islands, U.S.Wallis and FutunaWestern SaharaYemenZambiaZimbabwe

into this:

We've decided to use this on the new Drupalcon Denver website for choosing the speakers when submitting a session.

The module itself is little more than a configuration screen that allows you to choose the minimum number of options to show when the cursor is first placed within the select box's text field, and what elements to target.

Chosen is currently only available for Drupal 7.x-1.0 (though I'm sure would be a fairly simply backport to 6.x), and it's currently in use on over 50 sites. It has a dependency on the ever-useful Libraries module and is maintained by Arshad Chummun.

If you find this as intriguing a UX change as I do to the typical auto-complete widget, check it out!

newsletter-bot