Tooltip
tooltipShows brief guidance in an arrowed positioned layer on hover.
Usage
Basic usage
Display short prompts on hover/focus triggers; TooltipProvider unified management of opening delays.
<TooltipProvider>
<Tooltip>
<TooltipTrigger render={<Button variant="outline">Hover to view</Button>} />
<TooltipContent>Hulian Tips</TooltipContent>
</Tooltip>
</TooltipProvider>Prompt direction
side Controls the direction in which the prompt appears, and the arrow automatically points to the trigger.
<>
<Tooltip>
<TooltipTrigger render={<Button variant="outline">right</Button>} />
<TooltipContent side="right">To the right</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger render={<Button variant="outline">Down</Button>} />
<TooltipContent side="bottom">Down</TooltipContent>
</Tooltip>
</>Long copy
Long prompts are automatically wrapped to the maximum width.
<TooltipProvider>
<Tooltip>
<TooltipTrigger render={<Button variant="outline">Hover to view</Button>} />
<TooltipContent>Verify the maximum width and line wrapping performance of longer prompt copy</TooltipContent>
</Tooltip>
</TooltipProvider>When to use
Use Tooltip for short plain-text explanations on hover or focus, such as an icon's meaning, full truncated text, or action guidance. Use HoverCard for rich content or Popover for click-triggered content with actions. Configure delay and closeDelay on TooltipProvider, not Tooltip.
Import
import { Tooltip, TooltipTrigger, TooltipProvider, TooltipContent } from "@hulianui/ui"Props
TooltipContent:
| Name | Type | Default | Description |
|---|---|---|---|
| side | "top"|"right"|"bottom"|"left" | "top" | Preferred popup side. |
| align | "start"|"center"|"end" | "center" | Alignment along the trigger. |
| sideOffset | number | 8 | Distance from the trigger in pixels. |
| className | string | — | Additional class name. |
TooltipProvider accepts delay and closeDelay in milliseconds.
Slots
TooltipContent:
| Slot | Type | Description |
|---|---|---|
| children* | ReactNode | Tooltip copy. |
Use render on TooltipTrigger to provide the trigger. This is required for interactive elements such as buttons, links, and inputs; do not pass them as children.
Example
<TooltipProvider delay={0} closeDelay={0}>
<Tooltip>
<TooltipTrigger render={<Button variant="outline">Hover for details</Button>} />
<TooltipContent side="top" align="center">Hulian tooltip</TooltipContent>
</Tooltip>
</TooltipProvider>Usage guidelines
- Inject the trigger with `render`, rather than passing it as children. TooltipTrigger otherwise renders its own
<button>and places children inside it. A button child becomes invalidbutton > button, which TypeScript and builds do not catch but exposes two controls to assistive technology. Use<TooltipTrigger render={<button aria-label="Settings" onClick={onOpen}>⚓</button>} />; Base UI merges its handlers with yours.
```tsx
// Incorrect: creates button > button
<TooltipTrigger>
<button aria-label="Settings" onClick={onOpen}>Anchor</button>
</TooltipTrigger>
// Correct: Base UI merges handlers into this element
<TooltipTrigger render={<button aria-label="Settings" onClick={onOpen}>Anchor</button>} />
```
- TooltipContent's popup has no `role="tooltip"`. In E2E and acceptance tests, locate it by text or class rather than
[role="tooltip"]. - Put
delayandcloseDelayon TooltipProvider. Set both to zero for deterministic screenshots and hover checks. - In a flex row with ellipsis and
min-w-0, aninline-blockwrapper can expand to intrinsic width and defeat truncation. When usingrender, keep the trigger itselfblockandmin-w-0; see [[heroui-tooltip-trigger-inline-block-breaks-flex-truncation]].
Related
Playground
<Tooltip>
<TooltipTrigger render={<Button>Hover to view</Button>} />
<TooltipContent side="top" align="center">Hulian Tips</TooltipContent>
</Tooltip>