Skip to content

Tooltip

A tooltip component that will show on hover (desktop) or tap (mobile). It’s used to provide additional information about an element.

The tooltip can be positioned in various ways in relation to the anchor element. The default is auto.

The values for the position prop are:

  • auto: The tooltip will resort to the positions in this order: ‘top’, ‘bottom’, ‘right’, ‘left’.
  • top: The tooltip will be positioned above the anchor element, otherwise fall back on this order: ‘bottom’, ‘right’, ‘left’.
  • bottom: The tooltip will be positioned below the anchor element, otherwise fall back on this order: ‘top’, ‘right’, ‘left’.
  • left: The tooltip will be positioned to the left of the anchor element, otherwise fall back on this order: ‘right’, ‘top’, ‘bottom’.
  • right: The tooltip will be positioned to the right of the anchor element, otherwise fall back on this order: ‘left’, ‘top’, ‘bottom’.

The tooltip can be set to be open by default. This is useful for debugging or when you want the tooltip to be visible without user interaction.

Keep in mind, if a user interacts with another tooltip, the defaultOpen tooltip will close, even if it was not in view.

The tooltip can be styled with different colors. The default is default. The available colors are:

  • default
  • primary
  • success
  • warning
  • danger
  • info

The tooltip can be styled with different variants. The default is default. The available variants are:

  • default
  • outlined

The tooltip can be configured to have a gap between the anchor element and the tooltip. The default is 8px.

(Yes, this works with negative values too!)

The tooltip can be configured to have delays for showing and hiding. The default is 0ms for showing and 0ms for hiding.

By default, the tooltip will show on hover or tap. You can disable the tap activation by setting the hoverOnly prop to true.

By default, the tooltip will fade in when shown and out when hidden. You can disable this by setting the animate prop to false.

By default, the tooltip will show a pointer to indicate where the tooltip is pointing. You can disable this by setting the pointer prop to false.

You can control the tooltip programmatically by accessing the sui.tooltips object on the window. The following methods are available:

  • sui.tooltips.get(tooltipId: string): Get the tooltip instance by its ID, if it exists.
  • sui.tooltips.show(tooltipId: string): Opens the tooltip with the given ID, if it exists.
  • sui.tooltips.hide(tooltipId: string): Closes the tooltip with the given ID.