Skip to main content

Starwind UI v1.12 is now available!

Tooltip

Installation

Usage

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

Tooltip

The root component that manages tooltip visibility.

PropTypeDefault
openDelaynumber200
closeDelaynumber200
disableHoverableContentbooleanfalse
classstring-
<Tooltip>
<TooltipTrigger>
<Button variant="outline">Hover me</Button>
</TooltipTrigger>
<TooltipContent>Add to library</TooltipContent>
</Tooltip>

Additional Notes:

  • openDelay: Time in milliseconds to wait before showing the tooltip after hover
  • closeDelay: Time in milliseconds to wait before hiding the tooltip after leaving the trigger/content
  • disableHoverableContent: When true, prevents the tooltip from staying open when the user hovers over the tooltip content itself

TooltipContent

The positioned popup content.

PropTypeDefault
side"top" | "right" | "bottom" | "left""top"
align"start" | "center" | "end""center"
sideOffsetnumber4
avoidCollisionsbooleantrue
animationDurationnumber150
classstring-
<TooltipContent side="right" align="center">
Tooltip on right
</TooltipContent>

Additional Notes:

  • side: Which side of the trigger the tooltip appears on (top, right, bottom, or left)
  • align: Alignment of the tooltip relative to the trigger along the chosen side
  • sideOffset: Gap in pixels between the tooltip and the trigger element
  • avoidCollisions: When true, automatically repositions the tooltip to stay within the viewport
  • animationDuration: Duration in milliseconds for the open/close animation

TooltipTrigger

Wraps the element that triggers the tooltip.

PropTypeDefault
classstring-
<TooltipTrigger>
<Button variant="outline">Hover me</Button>
</TooltipTrigger>

Changelog

v1.3.0

  • style updates
  • add a caret to the tooltip content

v1.2.0

  • Add a data-slot attribute to all components to enable global styling updates

v1.1.2

  • Fix exit animation

v1.1.1

  • Add class will-change-transform to TooltipContent to improve CSS animations by providing a browser hint

v1.1.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts, allowing you to override any existing classes using the “class” prop.