Tooltip requires an element or a component as a single child – strings, fragments, numbers and multiple elements/components are not supported and will throw error. Custom components must provide a prop to get root element ref, all Mantine components support ref out of the box.
Custom components that are rendered inside
Tooltip are required to support
forwardRef function to forward ref to root element:
offset prop to a number to change tooltip position relative to the target element.
This way you can control tooltip offset on main axis only.
To control offset on both axis, pass object with
withArrow prop to add an arrow to the tooltip. Arrow is a
div element rotated with
arrowPosition prop determines how arrow is position relative to the target element when
position is set to
*-end values on
By default, the value is
center – the arrow is positioned in the center of the target element if it is possible.
If you change
side, then the arrow will be positioned on the side of the target element,
and you will be able to control arrow offset with
arrowOffset prop. Note that when
arrowPosition is set to
arrowOffset prop is ignored.
Events that trigger tooltip can be changed with
events prop, it accepts an object
with the following properties that determine which events will trigger tooltip:
hover– mouse hover event,
focus– focus/blur events excluding clicks on the target element,
touch– events for touchscreen devices,
To enable multiline mode, set
multiline prop to enable line breaks and
w style prop to set tooltip width:
inline prop to use
Tooltip with inline elements:
Stantler’s magnificent antlers were traded at high prices as works of art. As a result, this Pokémon was hunted close to extinction by those who were after the priceless antlers. When visiting a junkyard, you may catch sight of it having an intense fight with Murkrow over shiny objects.Ho-Oh’s feathers glow in seven colors depending on the angle at which they are struck by light. These feathers are said to bring happiness to the bearers. This Pokémon is said to live at the foot of a rainbow.
Tooltip is built with Transition component, it supports
All available premade transitions:
You can delay tooltip open/close events by setting
closeDelay props in ms:
Tooltip.Group component can be used to sync open and close delays for multiple tooltips:
Tooltip.Floating component has the same API as Tooltip component but tooltip will follow mouse:
If you want to build a component that can be used with Tooltip use forwardRef or other prop that will allow to get root element ref. This logic is applied to Tooltip and Tooltip.Floating components:
Tooltip follows WAI-ARIA recommendations:
- Tooltip body has
- Target element has
Tooltip.Floatingis ignored by screen readers
By default, Tooltip is not triggered by focus events and thus users who use a screen reader
or navigate with keyboard will not be able to get tooltip content. Set
events prop to enable
focus/blur tooltip events: