% @side_nav = "js" %>
Tooltips work cross browser and cross platform and are easily added to a page with a simple markup and class structure. You can apply the has-tip class to any element.
By default, the tooltip takes the width of the element that it is applied to, but you can override this behavior by applying a data-width attribute to the target element. The tooltip takes on the content of the targets title attribute.
The tooltips can be positioned on the "tip-bottom", which is the default position, "tip-top" (hehe), "tip-left", or "tip-right" of the target element by adding the appropriate class to them. You can even add your own custom class to style each tip differently. On a small device, the tooltips are full width and bottom aligned.
<%= code_example ' extended information ', :html %>Available class options:
tip-top
: Align the tip above the element you attach it to.tip-bottom
: Align the tip below the element you attach it to.tip-left
: Align the tip to the left the element you attach it to.tip-right
: Align the tip to the right the element you attach it to.If you don't want tooltips to interfere with a touch event, you can disable them for those devices. To do this, you'll just need to add a data-option to your tooltip, like so:
<%= code_example ' extended information ', :html %>You'll need to include foundation.tooltips.js
to make sure everything works properly. You'll also need to make sure to include zepto.js
and foundation.js
above the plugin. Above your closing </body>
tag include the following line of code and make sure you have the JS in your directory:
Read how to install Foundation JavaScript
Required Foundation Library: foundation.tooltips.js
Then, you'll need to add a data-attribute to make the JS work properly on that element. That looks like:
<%= code_example ' ... ', :html %>Tooltips now support data-options
configuration. You can use this functionality to disable tooltips selectively by defining data-options="disable-for-touch: true"
on your tip target.