---
title: Examples
slug: wip/snh7-examples
createdAt: 2023-07-20T14:45:03.180Z
---

# Examples

## Basic usage

To render a Tooltip, place the target as a child element and provide values to the Tooltip according to the API documentation.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/db8ed2be2de2e9229bf466f53d494880?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;186px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Tooltip with rich content

If you want to place markup inside a tooltip you can use the content slot

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/64e400a20b3b128141f7017ed7a7b685?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;224px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Make it follow the cursor

A Tooltip can follow the cursor on the y-axis when it is displayed before or after the target and on the x-axis when it is positioned above or below.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/567eee97b0085ff6496f107e30089801?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;383px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Make it follow the target

A Tooltip can follow the provided target when its position is changing.

:::hint{type="warning"}
**☝️ Watch out**

To follow the target accurately, the Tooltip updates its position continuously which might cause performance issues when used extensively.
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/ZEvPRNj/0bc56dac736d16980c586760fe0ce6ac?default-tab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;240px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Make it unreachable

By default, Tooltips can be reached by mouse to allow users to select and copy their content or interact with elements inside of them. In rare cases Tooltips that stick around overlaying other important elements that should be accessible as soon as a user moves their cursor out of the Tooltip's target.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/f85bf0c652fb407e3936b26ccf3d47a7?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;224px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

**Best Practice:**

- Tooltips should only become unreachable for users when they are overlaying important content that otherwise would not be accessible

## Changing the distance

The distance between the Tooltip and its target can be increased or decreased to better align it with other elements or achieve the desired white space.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/e9385ec9b76baea9ee19cadbb39442b9?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;224px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Updating the content

The content of a visible Tooltip might change based on an event or interactions during its lifetime. The Tooltip automatically updates its position anytime the `content`, by property or slot, changes. Additionally calling `update()` on a Tooltip instance allows it to recalculate its position based on its new dimensions if needed.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/a2625ded4a08ecbd170808716a7c081e?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;422px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Control the visibility

By default, a Tooltips visibility changes automatically on hover and focus gesture on the provided target. There are situations that require the visibility of a Tooltip to be controlled using a different signal or logic.

Using `controlled` in conjunction with `visible`allows the Tooltip to be fully remote-controlled from outside.

:::hint{type="info"}
**💡 Pro Tip**

When a Tooltip is set to be `controlled` it won't react to the hover and focus gesture on the target anymore. If a Tooltip should still react to hover gestures while its visibility is controlled, the `controlled`should not be set.
:::

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/0953442f6601c638c08b0c5ca2031a43?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;479px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

## Change its appearance

By default, Tooltip adapts to a light mode environment and appears light itself. In a dark mode environment, we recommend changing the Tooltips appearance to dark instead.

The appearance of a Tooltip can be set using the appearance property or by nesting it into a cosmos-mode component. Read more about the [Mode & Appearance](https://cosmos.redbull.design/wip/mode-and-appearance) concept.

:::Iframe{iframeHeight="0" code="<iframe title=&#x22;Embeded content from codepen.io&#x22; class=&#x22;no-border max-full-width full-height flex-grow&#x22; src=&#x22;https://codepen.io/redbulldesign/embed/2d4b7de4dfbb642fbee09843bed626f5?defaultTab=html%2Cresult&#x26;amp;editable=true&#x26;amp;theme-id=39623&#x22; height=&#x22;418px&#x22; loading=&#x22;lazy&#x22;></iframe>"}

:::

