0

How Create Nice Looking Dropdowns Using DropKick.js

In today’s tutorial we are going to use a nice jQuery plugin which will change the style of your select boxes by converting them to use divs and list items.

Dropkick Demo

The reason it will convert the select box to a div and list items is because now it is easier to style in what ever way you want. With normal select boxes you can style the top selected option but you can’t easily style the dropdown options of the select box. When these are list items you can apply a CSS class to the selected item and change the style.

What Is DropKick.js

Creating custom dropdowns is usually a tedious process that requires a ton of extra setup time. Oftentimes lacking conveniences that native dropdowns have such as keyboard navigation. DropKick removes the tedium and lets you focus on making it look good.

DropKick will also degrade gracefully so if Javascript is turned off then it will just keep the original select box.

How To Use DropKick.js

To start using DropKick.js you first need to download the files you need from GitHub.

Download

All you have to do in copy the files over to your project and include the DropKick CSS file and DropKick JS file.

Now all we have to do is create a new select box and assign DropKick to this new select box.

Assign DropKick to this select box by using the following Javascript method.

View the demo to see what this will create.

Demo

Attach A On Change Event

In most cases when using select boxes you want something to happen when you select and option.

In jQuery this can easily be done by assigning the change event to the select box.

To add a change event to the dropkick select boxes can be done by using the following code.

Add Your Own Styles

To create your own theme you need to assign a theme to your DropKick by using the following code.

Now copy the below CSS and use change the styles to however you want your new dropdowns to look like.

Download

DropKick.js files are hosted on Github so they are free to download and you will be told of any updates when you follow the project, just click the link below to download the files.

Download

To see how DropKick.js works view the demo page.

Demo

 

Leave a reply