Elegant Selects with Quick[select]

By  on  

Form elements have always allowed limited styling...which is why I hate working on form display.  And I started when form elements were virtually unstylable back in the Internet Explorer 4 days.  Of course we've come a long way but there's one element which is still somewhat difficult to style and isn't particularly elegant:  SELECT.  The element looks different from OS to OS and sometimes even browser to browser -- not ideal.

I recently found an awesome jQuery plugin to make the SELECT element more presentable, elegant, and stylable:  Quick[select].  Quick[select] turns SELECT options into clickable buttons with a traditional SELECT as a fallback.

The CSS

Quick[select] comes with a base stylesheet but you can style the option "buttons" in any way you'd like, as you can see in my demo.  Here are my basic styles:

.btn-group .btn {
	border: 1px solid #ccc;
	background: #eee;
	padding: 4px;
	border-radius: 4px;
	margin: 0 10px 0 0;
	font-size: 14px;
	display: inline;

	transition: background .3s, border-color .3s;
}
.btn-group .btn.active {
	background: #7ac9ed;
	border-color: #0c7bb6;
}

Quick[select] also has a helper for bootstrapped-driven sites, if that's your stack.

The JavaScript

Using Quick[select] is easy:  add the plugin to the page and then use the jQuery plugin syntax to create instances for given SELECT elements:

jQuery('#wakeup-time').quickselect({
	activeButtonClass: 'btn-primary active',
	breakOutValues: ['06:30', '07:00', '07:30', '08:00'],
	buttonClass: 'btn btn-default',
	selectDefaultText: 'Other',
	wrapperClass: 'btn-group'
});

The most important option is breakOutValues which generates clickable buttons for popular choices (specified by you) within the SELECT element.  You'll also want to set a custom selectDefaultText value for when the button which triggers the full display of the options.

Quick[select] is the best SELECT alternative that I've seen in a long time.  This plugin allows for elegant, stylish, and usable SELECT elements.  Go check it out and do your users a favor!

Recent Features

  • By
    CSS Animations Between Media Queries

    CSS animations are right up there with sliced bread. CSS animations are efficient because they can be hardware accelerated, they require no JavaScript overhead, and they are composed of very little CSS code. Quite often we add CSS transforms to elements via CSS during...

  • By
    Send Text Messages with PHP

    Kids these days, I tell ya.  All they care about is the technology.  The video games.  The bottled water.  Oh, and the texting, always the texting.  Back in my day, all we had was...OK, I had all of these things too.  But I still don't get...

Incredible Demos

  • By
    jQuery Comment Preview

    I released a MooTools comment preview script yesterday and got numerous requests for a jQuery version. Ask and you shall receive! I'll use the exact same CSS and HTML as yesterday. The XHTML The CSS The jQuery JavaScript On the keypress and blur events, we validate and...

  • By
    CSS :target

    One interesting CSS pseudo selector is :target.  The target pseudo selector provides styling capabilities for an element whose ID matches the window location's hash.  Let's have a quick look at how the CSS target pseudo selector works! The HTML Assume there are any number of HTML elements with...

Discussion

  1. Hi David. Thanks for highlighting my plugin!

  2. MaxArt

    This is a nice alternative way to display multiple options, but if a classic combo is needed I’d rely on the CSS appearance property, and fall back to the unstyled element for those browsers that don’t support it (hint: you can even use @supports in this case).

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!