Overlays

Tooltip

A tooltip is a small, informative message that appears when a user hovers over or focuses on an element for additional context.

Basic example

Default

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.

Tooltip on top

Colors

Semantic variants

Use modifier class `tooltip-{semantic-color}` with component class `tooltip-body` for colored tooltip.

Primary tooltip
Secondary tooltip
Accent tooltip
Info tooltip
Success tooltip
Warning tooltip
Error tooltip

Directions

Tooltip placements

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.

Tooltip on left
Tooltip on top
Tooltip on bottom
Tooltip on right

Illustrations

Image tooltip

Please utilize the provided example for creating an image tooltip.

The Himalayas About Himalayas The Great Himalayan mountain ranges in the Indian sub-continent region. Read more the himalayas , 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.

User details

Below given example shows user details tooltip upon hover.

Sophia
Sophia Aldrin @sophia23
Sophia
Sophia Aldrin
@sophia23

Lead Software Architect.
ABC Technologies

sophia23@gmail.com
+(101) 123-456-7891
Ontario, Canada
478 Following
1,984 Followers

Descriptive tooltip

Below given example shows descriptive tooltip upon hover.

Terms & Conditions
Terms and Conditions
  • Welcome to Semji. 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.

Destroy/Reinitialize

The `destroy` <a href="#destroy-method" class="link link-primary">method</a> is provided to facilitate the destruction of a tooltip element.

Tooltip

JavaScript behavior

Methods — Method usage

The `HSTooltip` object is contained within the global `window` object.

JavaScript
const tooltip = document.querySelector('.tooltip')
const { element } = HSTooltip.getInstance(tooltip, true)

destroy.addEventListener('click', () => {
  element.destroy()
})

Events — Event usage

METHOD| DESCRIPTION `on:show` | Triggered whenever a tooltip is showed. `on:hide` | Triggered whenever a tooltip is hidden.

JavaScript
const { element } = HSTooltip.getInstance('#tooltip-target-2', true)

element.on('show', (instance) => console.log("show"));
element.on('hide', (instance) => console.log("hide"));
Class referenceThe component, style, color, state, size and modifier classes available for this component.
ClassTypeDescription
tooltipcomponentBase class for tooltip component.
tooltip-togglepartBase class for toggling the display of tooltip.
tooltip-contentpartPlaces for tooltip content with popper.
tooltip-bodypartContainer for tooltip content.
tooltip-primarycolorTooltip with 'primary' color.
tooltip-secondarycolorTooltip with 'secondary' color.
tooltip-accentcolorTooltip with 'accent' color.
tooltip-infocolorTooltip with 'info' color.
tooltip-successcolorTooltip with 'success' color.
tooltip-warningcolorTooltip with 'warning' color.
tooltip-errorcolorTooltip with 'error' color.
tooltip-shown:{tw-utility-class}variantAdds specific tailwind classes when the tooltip is open.