Tooltip directive provides advisory information for a component. Tooltip is integrated within various PrimeVue components.
Tooltip is applied to an element with v-tooltip directive where the value of the directive defines the text of the tooltip.
Position of the tooltip is specified using a modifier. Valid values are top, bottom, right and left. Default position of the tooltip is right.
Adding delays to the show and hide events are defined with showDelay and hideDelay options respectively.
Tooltip gets displayed on hover event of its target by default, other option is the focus event to display and blur to hide. The both option displays it on hover and on focus, so keyboard users see it as well.
Tooltip is hidden when mouse leaves the target element, set autoHide to false to keep it visible while the pointer is over the tooltip content. This applies to pointer users only. The tooltip is not part of the tab order and closes when the target loses focus, so a link or a button inside the tooltip cannot be reached with the keyboard. Use Popover for interactive content.
Tooltip can use either a plain text or rich HTML content by setting escape to false.
Tooltip is also configurable by passing an object as the directive value.
Tooltip component uses tooltip role and when it becomes visible the generated id of the tooltip is defined as the aria-describedby of the target. A target that has its own aria-describedby keeps that value unchanged; to have the tooltip announced as well, give the tooltip an id and include it in that value.
Tooltip content is not reachable with the keyboard. The tooltip is rendered outside of the target in the DOM and closes when the target loses focus, so links or buttons inside it are only available to pointer users. Place interactive content in a Popover instead.
The default hover trigger responds to the pointer only, so a keyboard user who tabs to the target does not see the tooltip. Use the both trigger, v-tooltip.both or event: 'both', to display it on hover and on keyboard focus.
| Key | Function |
|---|---|
| tab | Moves focus to the target and displays the tooltip when the trigger is focus or both. |
| escape | Closes the tooltip wherever focus is. |