Tooltip

Jump to Props

Display information related to an element when the element receives keyboard focus or the mouse hovers over it.

Import

import { Tooltip } from "@vitality-ds/components";

Usage

A Tooltip presents a brief, informative message that appears when a user interacts with an element. It is usually initiated either through a mouse-hover gesture or when the element recieves focus via the keyboard. It is not focusable and cannot contain focusable content.

Use the Tooltip component to wrap the component you wish to trigger the tooltip, then pass the tooltip's content via the content prop.

<Tooltip content="Add Diagnostic Request (⌘+R)">
  <Button>
    <Request /> Add
  </Button>
</Tooltip>
Aim For
  • Provide brief and helpful content inside the tooltip. If you can't think of particularly helpful content, don't offer a tooltip
  • Provide additional explanation for a form field unfamiliar to some users or reasoning for what may seem like an unusual request.
  • Provide tooltips for unlabeled icons and IconButtons
Avoid
  • Users shouldn't need to find a tooltip in order to complete their task.
  • Don't add redundant content - it should be adding value.
  • Avoid hiding medically-critical information inside tooltips.

Tooltip Content

Aim to keep tooltips short and to the point. To handle larger amounts of content, the tooltip has a maxiumum width set and text will wrap over multiple lines. Tooltips are not interactive, nor can they handle rich content. Consider using a Popover component if you need this functionality.

<Tooltip content="This is a Patient Claim. Any correspondence from Medicare / Fund are sent directly to the patient.">
  <Button>Multi-line content</Button>
</Tooltip>

Preferred Positioning

As all tooltips are "collision-aware", their position will change depending on the space available in the viewport. You can however decide on their "preferred" position.

Side & Alignment

Setting the preferredSide property determines the preferred side against the trigger that the tooltip should be placed. The side will change to its opposite when collisions occur.

Setting the preferredAlignment property determines the position relative to the preferred side and changes the placement of the small arrow outside the tooltip. The side will change to its opposite when collisions occur.

Not applicable

Preferred Side
Preferred Alignment
Open State (for Preview)

Forward Refs

If the Tooltip is wrapping a functional component, ensure that the functional component accepts a ref using forwardRef.

() => {
  const MyButton = React.forwardRef((props, forwardedRef) => (
    <button ref={forwardedRef} {...props}>
      Button
    </button>
  ));

  return (
    <Tooltip content="This is a Patient Claim. Any correspondence from Medicare / Fund are sent directly to the patient.">
      <MyButton />
    </Tooltip>
  );
};

Figma Library

Figma.logo

Props

ariaLabel

Description

If the content within the tooltip is not descriptive enough or you have content that cannot be read by a screen reader, use aria-label as a more descriptive label. By default, screenreaders will announce the content inside the component.

Type

string

childrenRequired

Description

Element that triggers the tooltip when it receives keyboard focus or the mouse hovers it. React elements need to have refs forwarded to them.

Type

ReactNode

contentRequired

Description

The contents of the tooltip itself. For simple contents, pass a string. For multiline contents or rich text, pass a React component / JSX.

Type

ReactNode

isOpen

Description

The open state of the tooltip.

Type

boolean

onOpenChange

Description

Event handler called when the open state of the tooltip changes.

Type

(open: boolean) => void

preferredAlignment

Description

The preferred alignment against the trigger. May change when collisions occur.

Type

"start" | "center" | "end"

Default Value

center

preferredSide

Description

` The preferred side of the child element to align the tooltip against when open. Will be reversed when collisions occur.

Type

"top" | "right" | "bottom" | "left"

Default Value

top

showArrow

Description

Optionally hide the arrow.

Type

boolean

Default Value

© 2025