Skip to main content

Tooltip

Accessible tooltips with hover and focus triggers.

Usage

<w-tooltip>
<w-slot trigger><button>Hover me</button></w-slot>
<w-slot body><div>Helpful information</div></w-slot>
</w-tooltip>

Props

PropTypeDefaultDescription
openbooleanfalseWhether the tooltip is visible
placementstring"top"Position relative to trigger
delaynumber300Delay before showing (ms)
closeDelaynumber100Delay before hiding (ms)
portalbooleantrueTeleport to body for z-index safety

Slots

SlotElementDescription
triggerAnyElement that shows tooltip on hover/focus
contentAnyTooltip content

Events

EventDescription
showFired when tooltip becomes visible
hideFired when tooltip is hidden

Methods

MethodDescription
show()Show the tooltip immediately
hide()Hide the tooltip immediately

Keyboard

KeyAction
EscapeHide tooltip

Examples

Instant Tooltip

<w-tooltip delay="0" closeDelay="0">
<w-slot trigger><span>?</span></w-slot>
<w-slot body><div>Instant help</div></w-slot>
</w-tooltip>

Custom Placement

<w-tooltip placement="right">
<w-slot trigger><button>Info</button></w-slot>
<w-slot body><div>Tooltip on the right</div></w-slot>
</w-tooltip>

Available placements:

  • top, top-start, top-end
  • bottom, bottom-start, bottom-end
  • left, left-start, left-end
  • right, right-start, right-end

Rich Content

<w-tooltip>
<w-slot trigger><button>Details</button></w-slot>
<w-slot body>
<div>
<strong>Title</strong>
<p>Description with multiple lines</p>
</div>
</w-slot>
</w-tooltip>

CSS Transitions

.tooltip-enter { }
.tooltip-enter-from { opacity: 0; }
.tooltip-enter-to { opacity: 1; }

.tooltip-leave { }
.tooltip-leave-from { opacity: 1; }
.tooltip-leave-to { opacity: 0; }

Styling

w-tooltip w-slot[body] {
background: #333;
color: white;
padding: 8px 12px;
border-radius: 4px;
font-size: 14px;
max-width: 250px;
}

Accessibility

  • Content has role="tooltip"
  • Trigger linked via aria-describedby
  • Shows on both hover and focus
  • Dismissible with Escape key
  • Stays visible when hovering over content