Poshy Tip - jQuery Plugin for Stylish Tooltips

I almost hear you asking - why another jQuery tooltip plugin? Well, I actually never planned creating this plugin until I reached the final stages of designing this website and decided to add some pretty tooltips. So I started looking for a tooltip plugin that allows easily creating stylish tooltips and also includes the most useful features for such a script. However, I wasn't pleased with the results I found so I ended up writing a completely new plugin and am now making it available for all.

Demos

You might be eager to take a look at some examples so here is the demo page right away. And below you will find a short introduction.

Notable Features

OK, so apart from the awful name, is there anything interesting about this tooltip plugin?

A Single Background Image for Scalable Tooltips

Suppose you need to code a scalable tooltip that looks like this (i.e. a tooltip with auto width/height based on the content inside it):

A figure showing a tooltip mockup that should be used to create a scalable tooltip on the page

The Usual Approach

To achieve this with most similar plugins out there you would need to slice the image into multiple separate images - for the corners of the box, for the sides, etc.:

A figure showing how you would normally need to slice the mockup into 9 images in order to code a scalable tooltip

The Poshy Tip Approach

But since the tooltips only work when JavaScript is enabled anyway, why not apply some JS magic which would make our life easier and save our server some additional requests? This is exactly what Poshy Tip was designed to do. With this plugin, you can create a scalable tooltip by just using a single background image for the tooltip body:

With Poshy Tip you need just 2 images - one for the tooltip body + 1 for the arrow

You need to create one big image for the tooltip body - e.g. something like 1024x768 pixels (which should be enough for anything you may want to display inside a tooltip in the browser viewport). You then have to set it as a background image for the tooltip container DIV in the most trivial way:

.tip-yellow {
	...
	background-image: url(tip-yellow.png);
}

Poshy Tip detects when a background image has been set for the tooltip container DIV and creates a scalable frame from it that wraps the inner contents of the tip. Finally, you just need to specify what should be the size of the background image frame around the inner content by setting the following option:

bgImageFrameSize: 10 // pixels

And the result:

A figure showing the scalable frame created from the background image that wraps the inner DIV

You can, of course, tweak the margin/padding of the inner DIV if needed.

Advanced Positioning Options

With Poshy Tip you can position the tips relative to the mouse cursor or to the target element and align them in every possible way horizontally and vertically (note the alignTo, alignX and alignY options). In addition the script makes sure the tips are always displayed in the browser viewport and also automatically positions the arrow (if available) on the appropriate side of the tooltip body.

Asynchronous Loading of the Tooltip Content

Poshy Tip supports using a function for returning the tooltip content and the script also passes an update callback function as an argument to this function. By using this callback, you can easily update asynchronously the content of the tooltip after it has been displayed. You can see a quick example on the demo page.

Documentation

You can find usage examples and a list of the options and methods available on the demo page.

License

Like jQuery, Poshy Tip is dual licensed under the MIT and GPL licenses.

Git

The Poshy Tip source code is also available at GitHub:

git clone git://github.com/vadikom/poshytip.git

Liked this post?

Don't wait & subscribe to RSS or email updates now.
Quick Tip: Sharing is also easy with the share menu below. :)

Comments:

  • @Dan Brooke
    I had a similar problem about "Uncaught TypeError: Cannot call method 'data' of undefined"
    In my case it happens only calling "destroy" method.
    I solved problem deleting the line:

    delete this.$tip;

    Never heard about a "delete" command in JS...
    Hope this help you and other persons ;-)

    #92 by: Iceman on May 4, 2012 at 01:31
  • Excellent tool tip I have ever in my projects. You have done a great job. I have one query regarding dynamic data using ajax. I want to load content in tool tip using ajax call. Can you give me some overview? I really appreciate your work. Thanks :)

    #91 by: Naresh Chauhan on April 25, 2012 at 21:24
  • thank you very match

    #90 by: top on April 15, 2012 at 23:39
  • liveEvents does work =(

    #89 by: Tragedy on April 2, 2012 at 18:28
  • Hey, first of all the plugin is great and one of the best tip i have come across. Though it has some problem in chrome, the tip on displaying distorts the background graphic in surrounding areas as well as it takes too much time to load or to hide as well. Please, can you provide some fix.

    #88 by: Nitin on March 8, 2012 at 10:28
  • Excellent plugin. Questions/Suggestions:
    1. Is it possible for the plugin not to display itself if there is no title attribute? Right now it displays an empty box.
    2. More examples on how ot use content attribute with functions? Cannot seem to get it work.
    3. Is it possible to align the tip to a complete separate element? Wierd huh? I would like the tip to be shown exactly at the same position instead of right next to the field/link. Basically in Forms, I can have an area where tip is always shown as user tabs through the fields. This avoids it flickering with jQuery UI datepicter etc.

    #87 by: Paul George on March 8, 2012 at 00:24
  • Sorry, nevermind! - Just realized it's in the download. Thanks! :)

    #86 by: BenP on February 17, 2012 at 20:00
  • Great plugin :) Do you still have a demo page up? The current link is dead - would like to show it to a colleague so we might use it. Thanks!

    #85 by: BenP on February 17, 2012 at 17:22
  • Best tooltip I have see/ used to date. Much easier to use that qTip. Thanks.

    #84 by: Mark on February 7, 2012 at 19:24
  • Awesome plugin with best features. Thanks.

    #83 by: Ramakanth Ramaraju on January 27, 2012 at 11:25
  • Hi what should I do if I would like to do like this, on clicking I would like to pop up a tool tip with close button . I would like to implement and hover and click together on the same icon or control we have taken.

    #82 by: Dorababu on January 20, 2012 at 16:40
  • sonethinganotherasfsfsfs

    if I use p tag it gives a white rectangle .not a complete background !

    #81 by: mehmet on January 15, 2012 at 23:57

Post a Comment: