--- package: "@svenskaspel/ui" version: "4.5.0" document_type: "component-documentation" source: "@svenskaspel/ui/docs/tooltip.md" canonical_url: "/components/tooltip" usage_source: "src/app/(docs)/components/tooltip/page.mdx" --- # Tooltip Tooltip gives contextual information about a design element. ![Tooltip](/images/components/tooltip/tooltip-figma-910cb.webp) *** ## Usage Tooltips provide short, contextual information about an element — often used to describe icons, condensed labels, or actions when space is limited. They appear on hover or focus and disappear automatically when the element is no longer active. *** ## Anatomy The tooltip consists of three elements: the label that provides context, the container that holds the information, and the tip that indicates direction toward the anchor. ![Anatomy](/images/components/tooltip/tooltip-figma-c0854.webp) 1. Label – the message text providing context or clarification. 2. Container – the background surface that holds the label, styled with rounded corners. 3. Tip (Caret) – a small directional triangle that points toward the anchor element to indicate its relationship. *** ## Properties ### Label The label displays the accessible name of the trigger element. Keep text short and meaningful. Avoid wrapping where possible; wrap to a second line only when necessary. ![Label](/images/components/tooltip/tooltip-figma-732e4.webp) *** ## Behaviour ### Presentation Tooltips appear after a short delay (around 700 ms) when an element is hovered or focused. They fade in smoothly and hide immediately when the element is no longer active. Only one tooltip is visible at a time. ![Presentation](/images/components/tooltip/tooltip-presentation-316-1028-0.webp) ### Dismissing The tooltip disappears when the anchor loses hover or focus or when another tooltip is triggered. ![Dismissing](/images/components/tooltip/tooltip-dismissing-410-3710-0.webp) ### Text overflow Avoid long text. When wrapping occurs, the tip remains visually centered relative to the anchor. ![Text overflow](/images/components/tooltip/tooltip-figma-8ccc5.webp) ### Placement Tooltips position themselves automatically based on available space. The default placement is above the trigger element, but they can also appear below, to the left, or to the right when needed. ![Placement](/images/components/tooltip/tooltip-figma-4b205.webp) The tooltip automatically repositions to stay visible within the viewport, and the tip adjusts to indicate direction. *** ## Best practice ### Long labels ![Long labels – 1](/images/components/tooltip/tooltip-figma-dce88.webp) > **Do:** Keep labels short and simple. ![Long labels – 2](/images/components/tooltip/tooltip-figma-a9266.webp) > **Don't:** Avoid long or complex sentences that slow down scanning. ### Multiple tooltips ![Multiple tooltips – 1](/images/components/tooltip/tooltip-figma-3ff6c.webp) > **Do:** Show one tooltip at a time. ![Multiple tooltips – 2](/images/components/tooltip/tooltip-figma-cc6b0.webp) > **Don't:** Avoid multiple tooltips simultaneously. ### Width ![Width – 1](/images/components/tooltip/tooltip-figma-7f210.webp) > **Do:** Let the tooltip size adapt to its content. ![Width – 2](/images/components/tooltip/tooltip-figma-efa9c.webp) > **Don't:** Avoid a fixed width for the tooltip. *** ## Specs ![Specs](/images/components/tooltip/tooltip-figma-97d0c.webp) --- # Readme / API # `Tooltip` The `Tooltip` component is a reusable tooltip component built with [Base UI](https://base-ui.com/react/components/tooltip). It provides a flexible way to display additional information when users hover over or focus on an element. The tooltip includes an arrow that automatically points to the trigger element and supports positioning on all four sides. ## Features - **Arrow indicator**: Automatically positioned arrow that points to the trigger element - **Multiple positions**: Place tooltips on top, bottom, left, or right of the trigger - **Accessible**: Built with keyboard navigation and screen reader support - **Customizable**: Supports custom content and styling - **Flexible triggers**: Works with any element using Base UI's `render` prop ## Importing ```typescript import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@svenskaspel/ui/react/tooltip'; ``` ## Basic Usage ```typescript import * as React from "react"; import { Button } from '@svenskaspel/ui/react/button'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@svenskaspel/ui/react/tooltip'; const MyComponent = () => { return ( }>Hover

Add to library

); }; export default MyComponent; ``` ## Positioning Control tooltip placement using the `side` prop on `TooltipContent`. The arrow automatically adjusts to point toward the trigger element. ```typescript // Top position (default)

Tooltip on top

// Bottom position

Tooltip on bottom

// Left position

Tooltip on left

// Right position

Tooltip on right

``` ## Components ### `TooltipProvider` Wraps tooltips to share timing configuration, including `delay`, `closeDelay`, and `timeout`. A provider is optional; use one when multiple tooltips should share timing behavior. ### `Tooltip` The root component that manages tooltip state and behavior. ### `TooltipTrigger` The element that triggers the tooltip on hover or focus. Use the `render` prop to swap the rendered `