Skip to main content

Starwind UI v3.0 is now available! Migration guide

Installation

Usage

---
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/starwind/tooltip";
import { Button } from "@/components/starwind/button";
---
<Tooltip>
<TooltipTrigger>
<Button variant="outline">Hover me</Button>
</TooltipTrigger>
<TooltipContent>
Add to library
</TooltipContent>
</Tooltip>

Composition

Use a trigger and content inside the root:

Tooltip
├── TooltipTrigger
└── TooltipContent

Positioning

Control the position and alignment of the tooltip using the side and align props.

Delay

Customize the open and close delay using the openDelay and closeDelay props.

Alignment

Control the alignment of the tooltip relative to its trigger using the align prop.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Tooltip Trigger

Inherits span attributes.

Contains the following additional props:

Prop Type Default Toggle details
asChild boolean true
Description
Merges the component behavior and props into its child element.
Classification
Primitive override
Primitive prop
tooltip.Trigger.asChild

Tooltip Content

Inherits div attributes. Omits `tabIndex` and `tabindex`.

Contains the following additional props:

Prop Type Default Toggle details
disablePortal boolean false
Description
Keeps the public Portal wrapper inline instead of moving it to a target.
Classification
Wrapper prop
portalContainer string —
Description
Sets the CSS selector for the public Portal wrapper target.
Classification
Wrapper prop
positionerClass string —
Description
Adds classes to the generated floating positioner element.
Classification
Wrapper prop

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Tooltip.

Primitive API

Runtime API

Tooltip primitive
createTooltip from @starwind-ui/runtime/tooltip

Changelog

View version history v2.3.0 6 releases

v2.3.0

  • In Svelte, a defined open that you pass when Tooltip mounts now stays under your control, as in React and Vue. To change it, use bind: or update your state in the change callback. A form reset keeps it. If you pass undefined at mount, Tooltip keeps its own state.
  • Tooltip now opens on a native link or span in Vue and Svelte.
  • In Astro and Vue, a TooltipTrigger with plain text now renders a working trigger, so keyboard users can focus it.
  • Fixed Tooltip in Vue and Svelte staying hidden when its popup is replaced while open, for example when the key on the content changes.
  • Fixed a Tooltip trigger on a link or span that stayed disabled when a framework wrote disabled="false". On a native form control, any disabled attribute still disables it.
  • In Svelte, the Tooltip trigger now accepts a link in child. Before, it warned in development, type checks rejected the link, and ref did not run. Use the new TriggerChildPayload type for your snippet.

v2.2.1

  • Vue Tooltip keeps its previous open state when an open or close action is canceled.
  • Vue Tooltip respects the app-provided open value when it is re-enabled.
  • Reduced background work when a React page uses multiple menus, tooltips, or other portals.
  • Fixed nested Svelte overlays inside a dialog appearing behind their parent or failing to receive clicks.
  • Fixed open content losing its position at the trigger when the React or Vue component updates.
  • Fixed nested overlays appearing behind their parent in Vue and Svelte. Overlays can now render under the document body; if custom CSS or DOM queries require them to stay inside a parent, set a portal container or add data-floating-root to that parent.
  • Disabling a tooltip now cancels a scheduled opening. Re-enabling it restores trigger interaction.
  • Fixed React 18 retaining removed popup elements when the parent component stays mounted.

v2.2.0

  • Added portalContainer and disablePortal to TooltipContent for custom portal targets and inline rendering.

v2.1.0

  • Added positionerClass to TooltipContent so the floating positioner can be styled directly.
  • The default z-index is now on the positioner. Before, it was on the content.

v2.0.2

  • The default export in index.ts now has a name, TooltipParts, so framework tools show a clear name.

v2.0.0

  • Tooltip now gets its behavior from Starwind Runtime. Runtime handles the hover and focus delays, placement next to the trigger, and closing.
  • See the Tooltip Primitive for the unstyled parts and the behavior API.