Tooltip components are adopted from Preline UI components using Preline’s unstyled, headless Tailwind plugins to deliver accessible and responsive user interfaces.
We harnessed FloatingUI to supercharge our tooltip experience.
Class Name
Type
Description
tooltip
Component
Base class for tooltip component.
tooltip-toggle
Part
Base class for toggling the display of tooltip.
tooltip-content
Part
Places for tooltip content with popper.
tooltip-body
Part
Container for tooltip content.
tooltip-primary
Color
Tooltip with ‘primary’ color.
tooltip-secondary
Color
Tooltip with ‘secondary’ color.
tooltip-accent
Color
Tooltip with ‘accent’ color.
tooltip-info
Color
Tooltip with ‘info’ color.
tooltip-success
Color
Tooltip with ‘success’ color.
tooltip-warning
Color
Tooltip with ‘warning’ color.
tooltip-error
Color
Tooltip with ’error’ color.
tooltip-shown:{tw-utility-class}
Variant
Adds specific tailwind classes when the tooltip is open.
Utilize the class tooltip as the target for JavaScript to address the tooltip component, and use the component class tooltip-content for the tooltip container. Apply the Tailwind CSS display utility classes opacity-100 and visible to the tooltip-shown: modifier to toggle the visibility of the tooltip and make it visible.
Apply the component class tooltip-toggle to a button or any other element to trigger the appearance of the tooltip upon hovering.
Include any text or markup within the component class tooltip-body that you wish to display in the tooltip.
Use below given example for default tooltip on hover.
Utilize the JavaScript option class [--placement:{direction}] to specify the tooltip placement in various directions. Here, direction can be top, bottom, left, or right. By default, the tooltip is positioned at the top. Tooltip component supports the same placement options as the
Dropdown
component. However, as Tooltips are most commonly used with these four placements, we have provided examples for these specific options.
Please utilize the provided example for creating an image tooltip.
The
HimalayasAbout Himalayas
The Great Himalayan mountain ranges in the Indian sub-continent region.
Read more
, Asia's towering mountain range, separates the Indian subcontinent from the Tibetan Plateau. Mount Everest, Earth's
highest peak, and over 100 others surpass 7,200 m. Spanning Nepal, China, Pakistan, Bhutan, and India, they birth
major rivers like the Indus and the Ganges. Home to 600 million people, they shape South Asian and Tibetan cultures.
<p>
The
<spanclass="tooltip">
<spanclass="tooltip-toggle">
<ahref="https://en.wikipedia.org/wiki/Himalayas"class="link link-primary link-hover">Himalayas</a>
<spanclass="tooltip-content tooltip-shown:opacity-100 tooltip-shown:visible p-4"role="popover">
<spanclass="tooltip-body bg-base-100 flex max-w-64 sm:max-w-xs rounded-lg p-0 text-start">
<spanclass="text-base-content/80 flex w-1/2 flex-col justify-between p-2 sm:p-4 text-xs">
<spanclass="text-base-content text-base font-medium">About Himalayas</span>
The Great Himalayan mountain ranges in the Indian sub-continent region.
<ahref="https://en.wikipedia.org/wiki/Himalayas"target="blank"class="link link-primary link-hover flex items-center" >
Read more
<spanclass="icon-[tabler--chevron-right] rtl:rotate-180 mt-0.5"></span>
</a>
</span>
<imgsrc="https://lp-cms-production.imgix.net/2021-01/GettyRF_450207051.jpg"alt="the himalayas"class="h-40 w-1/2 rounded-e-lg object-cover" />
</span>
</span>
</span>
</span>
, Asia's towering mountain range, separates the Indian subcontinent from the Tibetan Plateau. Mount Everest, Earth's
highest peak, and over 100 others surpass 7,200 m. Spanning Nepal, China, Pakistan, Bhutan, and India, they birth
major rivers like the Indus and the Ganges. Home to 600 million people, they shape South Asian and Tibetan cultures.
</p>
Below given example shows descriptive tooltip upon hover.
Terms & Conditions
Terms and Conditions
Welcome to FlyonUI. If you continue to browse and use this TailwindCSS component library, you are agreeing to comply with
and be bound by the following terms and conditions of its use.
The content of the pages of this website is for your general information and use only. It is subject to
change without notice.
This website uses cookies to monitor browsing preferences. If you do allow cookies to be used, the
following personal information may be stored by us for use by third parties.
Neither we nor any third parties provide any warranty or guarantee as to the accuracy, timeliness,
performance, completeness, or suitability of the information and materials found or offered on this
website for any particular purpose.
Your use of any information or materials on this website is entirely at your own risk, for which we shall
not be liable. It shall be your own responsibility to ensure that any products, services, or information
available through this website meet your specific requirements.
<divclass="flex items-center gap-1">
<span>Terms & Conditions</span>
<divclass="tooltip [--placement:bottom]">
<divclass="tooltip-toggle">
<spanclass="icon-[tabler--help] hover:text-primary mt-1.5 size-4"></span>
<divclass="tooltip-content tooltip-shown:opacity-100 tooltip-shown:visible"role="popover">
<divclass="tooltip-body bg-base-100 text-base-content/80 max-w-xs rounded-lg p-4 text-start">
<spanclass="text-lg text-base-content">Terms and Conditions</span>
<ulclass="mt-4 space-y-1.5 text-xs">
<li>
Welcome to FlyonUI. If you continue to browse and use this TailwindCSS component library, you are agreeing to comply with
and be bound by the following terms and conditions of its use.
</li>
<li>
The content of the pages of this website is for your general information and use only. It is subject to
change without notice.
</li>
<li>
This website uses cookies to monitor browsing preferences. If you do allow cookies to be used, the
following personal information may be stored by us for use by third parties.
</li>
<li>
Neither we nor any third parties provide any warranty or guarantee as to the accuracy, timeliness,
performance, completeness, or suitability of the information and materials found or offered on this
website for any particular purpose.
</li>
<li>
Your use of any information or materials on this website is entirely at your own risk, for which we shall
not be liable. It shall be your own responsibility to ensure that any products, services, or information
available through this website meet your specific requirements.
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
Below is a demonstration of how to use the public methods. Apply the ID to the tooltip component class and target it using the methods. We’ve included JavaScript for a public method, enabling it to function when the method button is clicked. To test other methods, copy and paste the following code into your console, then click the button.
// This method is used in above example.
consttooltip=newHSTooltip(document.querySelector('#tooltip-target'));
constshowBtn= document.querySelector('#show-btn');
showBtn.addEventListener('click', () => {
tooltip.show();
});
Below is a demonstration of how to use the event. We’ve included JavaScript to handle the events, allowing it to execute when the corresponding event is fired. To test these events, monitor your console.