Feb 09 2013

Toolbar.js for jQuery and Bootstrap: Flexible Toolbars in iOS Style

Advertisement

No matter whether you like the design style of iOS or you don’t. We need not participate in the ongoing discussion about sceuomorphism. One topic cannot be disputed. I’m talking about the toolbar design Apple’s iOS introduced. Modern websites tend to adapt that concept more often than not. Tapping an icon or a link unveils more options. This is space-saving and an established implementation by now. The jQuery plugin Toolbar.js, created by Paul Kinzett from New Zealand, allows for iOS-style toolbars on any website. The tool is dead-simple to integrate.

Toolbars with Glyphicons from Twitter’s Bootstrap

Toolbar.js for jQuery offers a very simple, yet decent possibility of creating toolbars to attach to any element as well horizontally as vertically. An unlimited number of toolbar could be inserted that way. Kinzett chose to use the icon set, that Twitter’s Bootstrap utilizes and also sticks to the corresponding CSS. That way he maintains their responsiveness and allows for easy manipulation using established Bootstrap methods.

With hundreds of symbols at hand, even the most sophisticated toolbar should be possible. jQuery enthusiasts will feel at home immediately. As always, first thing to do is integrate the JavaScript:

1
2
<script src="jquery.min.js"></script>
<script src="jquery.toolbar.js"></script>

Then it is time to position the stylesheets for the toolbars and for the Bootstrap icons:

1
2
<link href="jquery.toolbar.css" rel="stylesheet" />
<link href="bootstrap.icons.css" rel="stylesheet" />

After that step you will want to define the toolbar itself, which could look like this:

1
2
3
4
5
6
7
<div id="user-toolbar-options">
    <a href="#"><i class="icon-user"></i></a>
    <a href="#"><i class="icon-star"></i></a>
    <a href="#"><i class="icon-edit"></i></a>
    <a href="#"><i class="icon-delete"></i></a>
    <a href="#"><i class="icon-ban"></i></a>
</div>

You see, that the icons are called via their respective classes from Bootstrap. The actions, that you want to be linked to the individual icon, have to be called via the element A. The last task to perform is the connection of the toolbar to the element, you want to trigger it.

1
 $('#element').toolbar( options );

Options are the position of the bar, which can be above or below as well as left or right from the element, where above and below show a horizontal bar, while left or right lead to a vertical look.

This definition:

1
2
3
4
$('#vertical-toolbar').toolbar({
    content: '#user-toolbar-options', 
    position: 'right'
});

leads to this visual presentation:

While this definition:

1
2
3
4
$('#user-toolbar').toolbar({
    content: '#user-toolbar-options', 
    position: 'top'
});

lets your toolbar look like this:

PIC_HORZ

The number of icons is only limited by your own reflection as to their reasonableness ;-)

Toolbar.js can be downloaded from Github. It is MIT licensed and can be used in private and commercial projects.

Related Links:

About the Author

Dieter Petereit is Noupe's Editor-In-Chief and a veteran of the web with over 25 years of experience in the world of IT. As soon as Netscape became available he started to do what already at that time was called webdesign and has carried on ever since. Almost a decade ago he started writing for several online publications, some well, some lesser known. Dieter is a heavy G-Plusser, so why not meet him over there?

Homepage

Comments and Discussions
search form
 
image description image description