Skip to content

Tooltip

Description

Tooltip is a component used to display various tips and hints, and serves as a wrapper over the Popper component.

Differences between Tooltip and Dropdown:

  • Tooltip appears only when hovering over the trigger.
  • It includes an arrow pointing to the trigger.
  • Tooltip contains only hints and additional information.

Component composition

Hint

Component consists of the following:

  • Hint
  • title attribute for the component which Hint component wraps

Tooltip

Component consists of the following:

  • Tooltip.Trigger
  • Tooltip.Popper
  • Tooltip.Title

DescriptionTooltip

Component consists of the following:

  • DescriptionTooltip.Trigger
  • DescriptionTooltip.Popper
  • DescriptionTooltip.Title

Themes

Tooltip has three themes: default, invert for use on a dark background, and warning for validation messages. In all cases, the text color changes to --text-primary-invert, and the background color changes accordingly.

TIP

Starting from version 3.1.0, you can set your own custom theme and change the background color.

Tooltip themes
ThemeAppearance exampleStyles
defaultbackground-color: var(--tooltip-default), border: 1px solid var(--border-secondary), box-shadow: var(--box-shadow-popper)
invertbackground-color: var(--tooltip-invert), border: 1px solid var(--border-tooltip-invert), box-shadow: var(--box-shadow-popper)
warningbackground-color: var(--tooltip-warning), border: 1px solid var(--border-danger-active), box-shadow: var(--box-shadow-popper)

Maximum width and offset

By default, the Tooltip has a maximum width of 250px, but you can set a different width if needed.

Offset and arrow placement

The distance between the trigger and the tooltip is 4px.

The placement of the arrow depends on the placement property, refer to the live examples in the Placement section.

Paddings and margins

The content area of the tooltip has a default padding of 12px.

Content margins and paddings

TIP

It's recommended to use a font size of 14px (--fs-200, --lh-200 tokens) for the title in non-advertising messages.

The image inside the tooltip has a size of 130px * 130px.

Data margins

To improve readability, it is recommended to use specific margins between labels and values inside the tooltip. Detailed recommendations for tooltip margins can be found in Data visualization and Summary.

Placement

The tooltip is built using the Popper.js library, allowing you to change its placement according to the Popper API.

The tooltip's position shouldn't change when scrolling the page, ensuring it remains visible to the user. The default tooltip placement is top.

Placement properties

tsx
import React from 'react';
import { Box } from 'intergalactic/flex-box';
import Button from 'intergalactic/button';
import Tooltip from 'intergalactic/tooltip';
import { Placement } from 'intergalactic/popper';

const styleBox = {
  display: 'grid',
  gridTemplateRows: '1fr 1fr 1fr',
  gridTemplateColumns: '1fr 1fr 1fr',
  gridGap: '2vw',
  padding: '60px',
};

const Demo = () => {
  const placements: Placement[] = [
    'top-start',
    'top',
    'top-end',
    'left-start',
    'right-start',
    'left',
    'right',
    'left-end',
    'right-end',
    'bottom-start',
    'bottom',
    'bottom-end',
  ];
  return (
    <Box style={styleBox}>
      {placements.map((placement, i) => {
        return (
          <React.Fragment key={i}>
            {['right', 'right-start', 'right-end'].includes(placement) && <div />}
            <Tooltip placement={placement}>
              <Tooltip.Trigger tag={Button}>{placement.toLocaleUpperCase()}</Tooltip.Trigger>
              <Tooltip.Popper>Hi there!</Tooltip.Popper>
            </Tooltip>
          </React.Fragment>
        );
      })}
    </Box>
  );
};

export default Demo;
import React from 'react';
import { Box } from 'intergalactic/flex-box';
import Button from 'intergalactic/button';
import Tooltip from 'intergalactic/tooltip';
import { Placement } from 'intergalactic/popper';

const styleBox = {
  display: 'grid',
  gridTemplateRows: '1fr 1fr 1fr',
  gridTemplateColumns: '1fr 1fr 1fr',
  gridGap: '2vw',
  padding: '60px',
};

const Demo = () => {
  const placements: Placement[] = [
    'top-start',
    'top',
    'top-end',
    'left-start',
    'right-start',
    'left',
    'right',
    'left-end',
    'right-end',
    'bottom-start',
    'bottom',
    'bottom-end',
  ];
  return (
    <Box style={styleBox}>
      {placements.map((placement, i) => {
        return (
          <React.Fragment key={i}>
            {['right', 'right-start', 'right-end'].includes(placement) && <div />}
            <Tooltip placement={placement}>
              <Tooltip.Trigger tag={Button}>{placement.toLocaleUpperCase()}</Tooltip.Trigger>
              <Tooltip.Popper>Hi there!</Tooltip.Popper>
            </Tooltip>
          </React.Fragment>
        );
      })}
    </Box>
  );
};

export default Demo;

Interaction

For the tooltip trigger, you can use formatted text, table headers, or interactive components like IconLink, Button, etc.

Appearance and hiding

Tooltip's appearance and hiding
Hidden
Cursor leaves the trigger
Cursor leaves the trigger or the tooltip itself (for tooltip with control)

Delay of appearance and hiding

Default values for tooltip appearance and hiding:

  • Appearance: 100ms
  • Hiding: 50ms

If the tooltip has interactive elements inside, the hiding time should be increased to 100ms.

Content

Hint

Hint contains only unformatted short text.

Tooltip

Tooltip can contain both unformatted and formatted single sentence of text, links, icons, and other interactive elements.

DescriptionTooltip

DescriptionTooltip can contain both unformatted and formatted large text, images, links and other interactive elements.

Usage in UX/UI

Main recommendations:

  • Use the tooltip to show hints and additional information only. Avoid adding complex functionality inside it.
  • Ensure that the tooltip does not overlap important information for the user.

TIP

For complex content and forms, use DropdownMenu.

If the tooltip trigger conveys information about a new feature, avoid duplicating the trigger text in the tooltip title. The title may not be necessary if the trigger text already explains the tooltip content.

When the trigger isn’t clear enough, add a clear title to the tooltip. Additionally, include a title when the trigger doesn't adequately explain the topic of the tooltip. For example, you can describe additional conditions in the header or expand on the trigger's idea.

Divide long text into paragraphs.

Avoid overloading the tooltip with information. A large amount of content can be inconvenient to view in the tooltip. If there is too much content and nothing can be removed, consider using a separate paragraph on the page or widget instead of a tooltip.

Ensure that the tooltip does not prevent users from interacting with nearby triggers.

Released under the MIT License.

Released under the MIT License.