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
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Whether the tooltip is visible |
placement | string | "top" | Position relative to trigger |
delay | number | 300 | Delay before showing (ms) |
closeDelay | number | 100 | Delay before hiding (ms) |
portal | boolean | true | Teleport to body for z-index safety |
Slots
| Slot | Element | Description |
|---|---|---|
trigger | Any | Element that shows tooltip on hover/focus |
content | Any | Tooltip content |
Events
| Event | Description |
|---|---|
show | Fired when tooltip becomes visible |
hide | Fired when tooltip is hidden |
Methods
| Method | Description |
|---|---|
show() | Show the tooltip immediately |
hide() | Hide the tooltip immediately |
Keyboard
| Key | Action |
|---|---|
Escape | Hide 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-endbottom,bottom-start,bottom-endleft,left-start,left-endright,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