There is a difference between tooltips used as a primary label or as a description. In most cases a button will already have its own label, so the tooltip will be used as a description with extra information, which is already set as default. Only in case of icon buttons you want to use the tooltip as the primary label. To do so you need to set the
For detailed information please read: inclusive tooltips.
You can easily change the placement of the content node relative to the invoker, by adjusting the
placement inside the
You can override the Popper configuration, the API is one to one with Popper's API, and includes modifiers.
- keepTogether: prevents detachment of content element from reference element, which could happen if the invoker is not in the viewport any more. If this is disabled, the content will always be in view.
- preventOverflow: enables shifting and sliding behavior on the secondary axis (e.g. if top placement, this is horizontal shifting and sliding). The padding property defines the margin with the boundariesElement, which is usually the viewport.
- flip: enables flipping behavior on the primary axis (e.g. if top placement, flipping to bottom if there is not enough space on the top). The padding property defines the margin with the boundariesElement, which is usually the viewport.
- offset: enables an offset between the content node and the invoker node. First argument is horizontal margin, second argument is vertical margin.
By default, the arrow is disabled for our tooltip. Via the
has-arrow property it can be enabled.
As a Subclasser, you can decide to turn the arrow on by default if this fits your Design System, by setting
this.hasArrow = true;in the constructor.
If you plan on providing a custom arrow, you can extend the
All you need to do is override the
_arrowTemplate method to pass your own SVG, and extend the styles to pass the proper dimensions of your arrow.
The rest of the work is done by Popper.js (for positioning) and the
lion-tooltip-arrow (arrow dimensions, rotation, etc.).