Overlays
Layout
Tooltip
A short label that appears on hover or focus. Use it to name an icon button or explain a control.
Install
import { Tooltip } from 'vael-ui'Playground
Placement, behaviour and animation
top
center
Usage
<script setup lang="ts">
import { ref } from 'vue'
import { Tooltip, Button } from 'vael-ui'
const open = ref(false)
</script>
<template>
<Tooltip v-model:open="open">
<template #trigger="{ setTriggerEl }">
<Button :ref="setTriggerEl">Trigger</Button>
</template>
Tooltip
</Tooltip>
</template>Motion New
Tooltip's box: values or hooks for its parts, like Popover's. Warm opens stay instant.
<Tooltip
:motion="{
initial: { panel: { opacity: 0, y: 8, scale: 0.98 } },
spring: { damping: 0.85, response: 0.35 },
}"
/>| Name | Type | Description |
|---|---|---|
initialexit | positionerpanel | Sets where each part comes in from and leaves to: any CSS property, plus x, y and blur. A plain number is px, or degrees for rotate. |
enterleave | (parts, context) => animation | Animates the parts with GSAP, motion or element.animate(). Return the animation and the component waits for it, and stops it if interrupted. |
morphlinkedexitOrder | 'trigger' | Record<string, LinkedMotion> | 'reverse' | morph: 'trigger' grows it out of the element that opened it. linked moves other elements with it, such as the page receding behind it. exitOrder: 'reverse' closes its children first. |
springdurationeasing | { damping, response } | number | string | Times all of it: a spring, or a duration in ms with an easing. Never both. |
false | boolean | Turns its motion off, for an animation of your own on its exposed elements. |
Accessibility
Follows the Tooltip pattern from the WAI-ARIA Authoring Practices Guide.
| Key | Action |
|---|---|
| Tab | Opens the tooltip when keyboard focus reaches the trigger, and closes it when focus leaves. |
| Escape | Closes the tooltip without closing a dialog or menu around it. |
- The panel has
role="tooltip". While it’s open, the trigger’saria-describedbyincludes its id, and your own ids stay. A tooltip that only repeats the trigger’s name isn’t added, so it isn’t read twice. - It opens on
:focus-visibleonly, so a mouse click doesn’t open it. On touch, a 500 ms long press opens it, and it closes 1.5 s after you lift your finger or when you tap elsewhere. - The tooltip describes the trigger but doesn’t name it. An icon-only trigger still needs an
aria-label.v-tooltipwith text sets thataria-labelon a button or link with no name of its own. - Keyboard users can’t move into the tooltip. Put links and buttons in a Popover.
- The trigger must be focusable for keyboard users to reach the tooltip.