Theming of form items and then performance issues is one of the hard jobs. I am not mentioning IE here because Dear internet Explorer has crosses all limits of giving pain. Now the happy news is that IE is dead and I am sure it will be burning in the deepest hole of hell. The pain, the time waste that IE has done in past years will not be fixed by Microsoft ever. Even if they sell their shares and pay all money to Front-End Developers.
I think I am going far with this now, back on the track. There are many ways to theme form items. Browsers and Operating systems render form items differently. Which is a reason for design inconsistencies across platforms. Depending on the amount of theming you have to do for form items and select boxes particularly.
Starting with the below code in your style sheets will give you jump start and idea what of what else to achieve. Its important to cascade the default appearance.
What if we have to select multiple options from drop-down or we have a very long drop-down list and (For example country names) and scrolling through is time consuming. What if we have a search inside the select list?
All this is possible with lot of libraries available but here we are focusing on one of the best libraries select2. Select2 gives us a customizable select box with support for searching, tagging, remote data sets, infinite scrolling, and many other highly used options.
Particularly theming the select drop-down, which isn’t easy. border, drop-down arrows option list cant be themed easily without certain JS. We will unleash select2 for these things. It isn’t recomended to use Select2 for small customizations. If you want maximum out of it then it can be used otherwise there will be some small performance issues.
Its simple to use select2 in any site but with drupal there comes small customizations.
Firstly we will install select2 library and declare in our theme.libraries.yml
in my case I have put all libraries in libs folder. Now we need to do some little customizations to make it work on our drupal site. Actually it is mainly a class and wrapper issues that select2 isn’t getting applied with just library setup.
in our common JS file, we need to add some customised code. For me it is.
Now that new markup is generated and you can easily theme it, because it will be skinned in divs rather than
Go ahead and theme as per your comps.