How To Add Tooltips to Elements in Oxygen Builder

by Abdelouahed

Updated: Sep 23, 2019 

Tooltips are considered to be a good user experience enhancement, which can allow visitors to learn more information about clickable elements like icons, buttons, and links

To show tooltips on HTML elements, you need to use Javascript libraries that handle the display and positioning of these tooltips relative to the target button or link. There is quite a large number of choices out there like Tippy and Popper, these libraries require some initialization, either using a custom Javascript code or using html5 data-attributes which is the most intuitive solution.

That's easy to do if you are creating HTML template or custom WordPress themes, But to do so in Oxygen, there is no built-in solution for this, fortunately, we have developed our own attributes manager for this website builder which allow you to manage different tooltip content and settings for each element on your website with writing custom code!

Add attributes to Oxygen

First, Tippy.js require only attribute which is data-tippy-content which should contain the tooltip text and we will register it for all the required elements using the Oxygen Attributes plugin

That attribute will allow you add a tooltip to the top of the element, but Tippy.js also have an optional attribute data-tippy-placement to control the position of the tooltip, if you want you to create that attribute, fill the details like in the screenshot below:

The field Condition is used here to organize the editing UI in Oxygen, in this case, the second attribute field for data-tippy-placement won't be shown if data-tippy-content is empty.

That's it for the basic attributes needed for this tooltips library, you can check the official Tippy.js documentation to learn more about extra attributes you may need to further customize the tooltip animation and delay, etc.

Load the required libraries

I have chosen to use Tippy.js to handle all the magic of this guide, so first of all, you need to add a code block to the very bottom of your page or template and paste the following HTML code in the PHP & HTML section:

<script src="[email protected]"></script> <script src="[email protected]"></script> <script> window.addEventListener('load', function() { tippy('[data-tippy-content]'); }); </script>
Code language: HTML, XML (xml)

The above code will add the tooltips to any element having the custom attribute data-tippy-content we just created, next, we need to fill these attributes to make the tooltips show some information.

Add tooltips to buttons

Now you are just one step away from adding these beautiful tooltips in your website elements: fill the values of the attributes, like in this demo screenshot

The end result should be something like this

This is how easy you can create and manage tooltips in Oxygen using the attributes addon and the cool Tippy.js library, just remember that you can do much more cool things with Oxygen Attributes not just tooltips, the limit is your imagination and creativity.

If you have any comments or need more information on this topic, please post them in the related  facebook post

Discuss on Facebook

Interested in more posts this?

Join over 200 subscribers of our spam-free mailing list, to get email notifications whenever we publish a new blog post.

Clean plugins

Advanced Scripts

Advanced Scripts is the best scripts manager on the market. Besides PHP, CSS, and Javascript, you can also write SCSS and LESS code, use custom hooks, and all of that in a better interface.

Hydrogen Pack

A pack of missing features from the Oxygen builder; copy-paste elements and styles, enhanced structure panel, 60+ customizable shortcuts, sandbox mode, and more handy tools to improve your workflow!

Oxygen Attributes

The way our solution handles the attributes makes all the difference. It offers a centralized attributes manager, more field controls, CSS properties, target sub-elements, and much more.