Tooltip
Allow users to see a short, context-specific text message when they hover over or focus on an element
# Tooltip vs. Popover
To clarify the differences between Tooltip and Popover, a short description is provided.
| Component name | Usage | 
|---|---|
| Tooltip | A tooltip is a short context-specific text message that appears temporarily when a user hovers or focuses on an element. | 
| Popover | A popover is a customizable container that may contain interactive elements. It remains visible until the user clicks the close button, clicks outside of it, or tabs to the next focusable element. | 
#Examples
A Tooltip is a concise contextual message connected to an attached element, such as an icon or button, which offers supplementary information about it. By default, a Tooltip is hidden and become visible when hovered over or focused on an attached element. A Tooltip should be used sparingly, as it provides limited and specific information to an attached element.
A Tooltip consists of two elements:
- Caret tip: a guide that directs the user's attention to the trigger that activated the Tooltip.
- Container: the area that displays the additional information.
#Variant
Use the variant property to find out which variant suits your use case. The following sections explain how to use them.
Pay attention to user interaction with the Tooltip. Interactive variants are displayed only on focus state, whereas text and icon only variants require keyboard users to navigate to the attached element and press the Space Bar or Enter keys to display them.
| Variant | Example | Use case | 
|---|---|---|
| Text | Provides non-essential supplemental information to help users make decisions. For example, it can be used when data is missing from a table cell. | |
| Icon only | Describes the meaning or purpose of icons without visible labels. | |
| Interactive | Describes the function or action of an interactive UI element, such as a button. | 
#Text variant
Use the text variant to provide concise, relevant, and helpful information. The The tooltip's text should be clear and standalone, needing no additional explanation. Nest Tooltip inside the text's HTML or Fancy tags and wrap it around the string or number. Place the information in the content property of the component.
<InlineText>
	<Tooltip
		variant={{ type: "text" }}
		content="The Digital Certainty Index (DCI) is a measure of the quality and potential impact of a site's digital presence."
	>
		DCI
	</Tooltip>
</InlineText>#Use a text variant in a card header
This is another contextual example with a text variant. It shows how to add a Tooltip to a Card header. However, if the user is unfamiliar with the title in the Card header, clearly display an explanation using small and subtle Inline text below a title in the Card header instead. See Best Practices.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ultricies nisl neque, ut feugiat arcu dapibus nec. Nulla facilisi. Ut scelerisque purus at tristique bibendum.
<Card>
	<Card.Header>
		<H2>
			<Tooltip
				variant={{ type: "text" }}
				content="Web Content Accessibility Guidelines (WCAG) is developed through the W3C process in cooperation with individuals and organizations around the world, with a goal of providing a single shared standard for web content accessibility that meets the needs of individuals, organizations, and governments internationally."
			>
				WCAG
			</Tooltip>
		</H2>
	</Card.Header>
	<Content>
		<Paragraph>
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ultricies nisl neque, ut
			feugiat arcu dapibus nec. Nulla facilisi. Ut scelerisque purus at tristique bibendum.
		</Paragraph>
	</Content>
</Card>#Change an icon in a text variant
Use the icon property to change the icon in a Tooltip. The default icon is IconHelpOutline, aliased as Tooltip.icon. It is highly recommended to stick to the default icon for better user recognition and consistency.
<InlineText>
	<Tooltip
		variant={{
			type: "text",
			icon: (
				<Icon size={Tooltip.iconSize}>
					<IconPotentialIssue />
				</Icon>
			),
		}}
		content="Potential issues need to be verified by a human being."
	>
		Potential issue
	</Tooltip>
</InlineText>#Change an icon size in a text variant
Use the size property of the Icon component to adjust the size of the tooltip icon. This enables you to match the size of the tooltip icon with its associated text. The default value is medium, aliased as Tooltip.iconSize.
<InlineText size="large">
	<Tooltip
		variant={{
			type: "text",
			icon: <Icon size="large">{Tooltip.icon}</Icon>,
		}}
		content="An SEO Activity Plan is a toolbox for customizing an adjustable workflow, allowing users to engage with all aspects of Search Engine Optimization (SEO) to meet their website goals and challenges."
	>
		Activity plans
	</Tooltip>
</InlineText>
<br />
<InlineText size="medium">
	<Tooltip
		variant={{
			type: "text",
			icon: <Icon size="medium">{Tooltip.icon}</Icon>,
		}}
		content="An SEO Activity Plan is a toolbox for customizing an adjustable workflow, allowing users to engage with all aspects of Search Engine Optimization (SEO) to meet their website goals and challenges."
	>
		Activity plans
	</Tooltip>
</InlineText>
<br />
<InlineText size="small">
	<Tooltip
		variant={{
			type: "text",
			icon: <Icon size="small">{Tooltip.icon}</Icon>,
		}}
		content="An SEO Activity Plan is a toolbox for customizing an adjustable workflow, allowing users to engage with all aspects of Search Engine Optimization (SEO) to meet their website goals and challenges."
	>
		Activity plans
	</Tooltip>
</InlineText>#Use a text variant to explain no data
Use a text variant to explain the absence of data in a table cell or similar location, with a brief explanation provided.
<Tooltip
	variant={{ type: "text" }}
	content="The page doesn't contain enough text to measure readability."
>
	Unavailable
</Tooltip>#Icon only variant
Use the icon-only variant for clear and concise descriptions of static icons. Wrap the Tooltip around the Icon and put the label in the content property.
Only provide a static icon with a Tooltip, instead of a visible label, when:
- The label doesn't contain information essential to task completion.
- Placing label in the UI would add significant visual clutter.
<Tooltip variant={{ type: "icon-only" }} content="Desktop device">
	<Icon>
		<IconDesktop />
	</Icon>
</Tooltip>#Use an icon only variant to explain no data
The icon only variant can be used when there is no accompanying text, but only as a last resort due to technical difficulties. It is recommended to include a text snippet.
<Tooltip variant={{ type: "icon-only" }} content="No data available">
	<Icon size={Tooltip.iconSize}>{Tooltip.icon}</Icon>
</Tooltip>#Interactive variant
For interactive UI elements lacking a label, utilize the interactive Tooltip to clarify their purpose or action. Wrap the Tooltip around the element and provide clarification in the content property. An example of this is an icon-only button, as shown below.
Only provide interactive UI elements with an icon, instead of a visible label, when:
- Space in the UI is limited and/or the UI element is repeated many times on the page.
- The icon is universally known, such as a trash can for deleting.
<Tooltip variant={{ type: "interactive" }} content="Delete item">
	<Button onClick={() => console.log("clicked")}>
		<Icon>
			<IconDelete />
		</Icon>
	</Button>
</Tooltip>#Placement
Position a Tooltip using the placement property to avoid obstructing relevant information crucial to the user's task. The Tooltip offers 12 placement options, with top as the default. A Tooltip can also be positioned to the right, left, bottom of the trigger element. 
Keep in mind that the Tooltip will only appear in the preferred placement if there's enough space available.
<Tooltip
	variant={{ type: "text", learnMoreAbout: "this tooltip's preferred placement" }}
	content="My preferred placement is to the right."
	placement="right"
>
	<InlineText>Tooltip placement</InlineText>
</Tooltip>#Properties
| Property | Description | Defined | Value | 
|---|---|---|---|
| variantRequired | objecttext, icon-only, or interactive. Please read the styleguide documentation for guidance. | ||
| contentRequired |  | string | number | elementContent to display when the tooltip is active | ||
| childrenOptional |  | string | number | object | element | objectThe element that the tooltip clarifies the function or meaning of | ||
| placementOptional | "bottom" | "bottom-end" | "bottom-start" | "left" | "left-end" | "left-start" | "right" | "right-end" | "right-start" | "top" | "top-end" | "top-start"Preferred placement for the tooltip when active | ||
| aria-labelOptional | stringOverride the aria-label for the button wrapping the anchor element. Only use aria-label for the “icon-only” variant in special cases, since it overrides the content of the HTML element inside of the tooltip | ||
| aria-describedbyOptional |  | stringOverride the aria-describedby for the button wrapping the anchor element | ||
| onHideOptional | functionCallback that's executed after the tooltip content gets hidden | ||
| forceOpenOptional | booleanForce the tooltip to be in its visible state | ||
| noDelayOptional | booleanRemove the delay when showing and hiding the tooltip | ||
| hideContentOptional | booleanHide the content visually and for assistive technology | ||
| updateKeysOptional | unknown[]Key to control updates to the placement of the popover. Provide a different value when an update is desired | ||
| data-observe-keyOptional | stringUnique string, used by external script e.g. for event tracking | ||
| classNameOptional | stringCustom className that's applied to the outermost element (only intended for special cases) | ||
| styleOptional | objectStyle object to apply custom inline styles (only intended for special cases) | 
#Guidelines
#Best practices
#Do not use when
#Accessibility
Explore detailed guidelines for this component: Accessibility Specifications
#Writing
#Notable Changes
#Version 47.0.0
Variants icon-short-label and icon-long-label merged to a common icon-only variant.
#Version 0.0.x
- It's now required to choose from one of four Tooltipvariants:- text
- icon-short-label
- icon-long-label
- interactive
 
- The interactivevariant replaces theInstant Tooltip Wrappercomponent.
- The anchorproperty has been removed. TheTooltipshould now always be wrapped around its associated UI element.
- The Tooltipnow always comes with anaria-label. It’s (partly) set with thevariantproperty’slearnMoreAboutparameter for thetextandicon-long-labelvariants. It’s automatically set for theicon-short-labelandinteractivevariants.
- Eight new value options have been added to the placementproperty.
- It’s now possible to change both the Tooltip icon and its size, when using the textvariant, with theiconproperty.