Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Overlays

  • Dialog
  • Modal
  • AlertDialog
  • Drawer
  • Popover
  • Tooltip
  • HoverCard
  • Glimpse
  • HeroVideoDialog
  • ElementSelectionOverlay

Messages

  • Alert
  • InterceptCard
  • Callout
  • Banner
  • Toast
  • Notification
  • ServiceMessage
  • Result
  • GiftFeed
  • FloatingReactions
  • Popconfirm

Loading and Progress

  • Spin
  • Spinner
  • Progress

Guidance

  • Tour

Tooltip

tooltip

Shows 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.

tsx
<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.

tsx
<>
  <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.

tsx
<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

ts
import { Tooltip, TooltipTrigger, TooltipProvider, TooltipContent } from "@hulianui/ui"

Props

TooltipContent:

NameTypeDefaultDescription
side"top"|"right"|"bottom"|"left""top"Preferred popup side.
align"start"|"center"|"end""center"Alignment along the trigger.
sideOffsetnumber8Distance from the trigger in pixels.
classNamestring-Additional class name.

TooltipProvider accepts delay and closeDelay in milliseconds.

Slots

TooltipContent:

SlotTypeDescription
children*ReactNodeTooltip 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

tsx
<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 invalid button > 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 delay and closeDelay on TooltipProvider. Set both to zero for deterministic screenshots and hover checks.
  • In a flex row with ellipsis and min-w-0, an inline-block wrapper can expand to intrinsic width and defeat truncation. When using render, keep the trigger itself block and min-w-0; see [[heroui-tooltip-trigger-inline-block-breaks-flex-truncation]].

Related

Dialog · Modal · AlertDialog · Drawer · Popover · HoverCard

Playground

<Tooltip>
  <TooltipTrigger render={<Button>Hover to view</Button>} />
  <TooltipContent side="top" align="center">Hulian Tips</TooltipContent>
</Tooltip>
PreviousPopoverFeedbackNextHoverCard

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Example
    • Usage guidelines
    • Related
  • Playground