---
title: Tooltip
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Tooltip } from '@telus-uds/components-web'
import { Tooltip as BaseDocs, Typography } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# Tooltip

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D3035%253A24554" />

```jsx live
<Tooltip content="This is a tooltip" />
```

## Introduction

`Tooltip` provides a descriptive and detailed explanation or instructions. It can be used next to an input label to help
a user fill the input, or as a standalone component.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

- You may use one when the information is useful only to a small percentage of users (ie. tech savvy people wouldn't need this info).
- Tooltips may also be useful when vertical space is an issue.
- Tooltip uses `button` and `alert` roles instead of the `tooltip` role because the latter is intended for mouseover tooltips and those are considered a bad accessibility practice.

By default the `TooltipButton` component will be used as a control for triggering the tooltip, but you may attach
a tooltip to any other component.
A render function can be used to adjust the control's styling on state changes (hover, focus, etc.).

```jsx live
<Tooltip content="Amazing 😍">
  <span>Click on this text to open the tooltip</span>
</Tooltip>
```

### Positioning

By default a `Tooltip` will be automatically positioned in a way that ensures it fits within the viewport.
You may use the `position` prop to suggest a position - it will be used, unless the tooltip would end up outside the viewport.

```jsx live
<Tooltip content="This tooltip's position is forced to left" position="left" />
```

#### `inline` prop

On the web, `Tooltip`'s icon button can be placed inline within other elements by passing `inline` prop.

```jsx live
<Typography>
  Our commitment to service <Tooltip inline content="This is service note" /> is demonstrated in
  everything we do.
</Typography>
```

### Activate on hover

By default, the `Tooltip` will be activated on click. You may use the `activateOnHover` prop to activate it on hover.

```jsx live
<Tooltip content="This tooltip is activated on hover" activateOnHover />
```

### Override tooltip button tokens

You may override the default tokens for the tooltip button by passing a `tooltipButtonTokens` prop.

```jsx live
<Tooltip
  content="This tooltip has custom button tokens"
  tooltipButtonTokens={{ icon: Icons.EyeMasked }}
/>
```

### Accessibility

`Tooltip`'s control is announced as a button with a label encouraging interaction. When open, the `Tooltip` receives an
alert role, so that it's appearance is picked up by screen readers.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable base={BaseDocs} component="Tooltip" />

## Variants

### Inverse

- Use on dark backgrounds.

```jsx live
<div style={{ backgroundColor: 'black', padding: 20 }}>
  <Tooltip content="This is a tooltip" variant={{ inverse: true }} />
</div>
```

## Feedback

<Feedback component="Tooltip" />
