A versatile component for displaying contextual information on hover.
The JTB-Tooltip is a versatile component designed to provide contextual information when users hover over an element. It enhances user experience by displaying helpful tips, descriptions, or additional information without cluttering the main interface.
With customizable positioning, animations, and styles, the JTB-Tooltip is suitable for a variety of use cases, ensuring information is conveyed seamlessly and effectively within your web applications.
To create a JTB-Tooltip element in your projects, use the <jtb-tooltip>
tag in the way that suits your needs. Whether you add elements dynamically with JavaScript, directly in HTML, or through server-side languages like PHP, it doesn’t matter. As long as the component is correctly initialized, JTB_MD will handle the request of yours and render the element as specified.
Once you've defined your tooltip element and specified its content, you can make any element its trigger by adding the jtb-tooltip
attribute to it. The attribute value needs to be the ID of your tooltip element.
As demonstrated in the example above, JTB-Tooltip elements are blank containers that allow you to place any content inside them. From simple texts to complex structures, you have the flexibility to include anything within the tooltip. To define the content, simply place your desired elements between the opening and closing tags of the <jtb-tooltip>
component.
JTB-Tooltip containers are fixed elements within the DOM that reposition themselves based on their triggers. You can nest tooltips by placing trigger elements inside other tooltips. This allows for more complex and layered tooltip interactions, providing enhanced flexibility in your UI design.
If you need to create a gap between your trigger element and your tooltip container, you can specify it via adding offset
attribute in your JTB-Tooltip element with your desired gap in pixels as value.
To specify position of tooltip container based on its trigger you can use position
attribute of it. Possible values are TL | TC | TR | RT | RC | RB | BR | BC | BL | LB | LC | LT
where each letter are the first letter of edges.
During the positioning stage, the jtb-tooltip follows two fundamental principles:
With these two principles JTB_MD aims to make JTB-tooltip elements stay on screen as much as possible and provide a smooth user experience.
It has position='TL'
It has position='TC'
It has position='TR'
It has position='LT'
It has position='LC'
It has position='LB'
It has position='RT'
It has position='RC'
It has position='RB'
It has position='BL'
It has position='BC'
It has position='BR'
Since JTB-Tooltip elements are blank containers, they offer complete flexibility for you to manipulate and style them as needed. You can easily apply your custom design or appearance attributes onto them. However, to simplify your workflow, we've also provided predefined attributes for JTB-Tooltip elements that enable you to customize their style and appearance with ease.
To change the shape of the tooltip container, use the shape
attribute with your desired value.
Available options are: default | rect
.
shape='default'
shape='rect'
JTB Tooltips are components built upon the jtbComponent
element. As a result, they inherit all global listeners and callbacks, ensuring consistent event handling. For a detailed overview, refer to the Base component - Core page.
JTB Tooltips inherit all core methods from the base component, ensuring fundamental functionality such as show()
, hide()
, reload()
, and destroy()
remain available. For a complete list of inherited methods, visit the Base Component - Core page.
In addition to these inherited methods, JTB Tooltips introduce specialized methods tailored to their unique functionality:
reposition()
- Repositions container depending on current position of its trigger.While each property on its own brings unique changes to the elements, combining them can help you create the perfect one.
For making it easier to navigate through all the attributes, we’ve created a comprehensive table for you. Below, you can find a list of all and their uses.
Copyright © 2025 JTBLabs - All rights reserved.