Skip to content

Tooltip ​

A tooltip names or clarifies the thing it points at. It appears on hover and on focus, and it is never the only place something is said — a reader on a touch screen may never see it at all.

ts
import { Tooltip, TooltipContent, TooltipTrigger } from "ropav";

Placement ​

TooltipContent takes the placement. It flips to the opposite side when there is not room, so these four are a preference rather than an instruction.

tooltip-placements.vue
vue
<script setup lang="ts">
import { Button, Tooltip, TooltipArrow, TooltipContent } from "ropav";

const placements = ["top", "right", "bottom", "left"] as const;
</script>

<template>
  <Tooltip v-for="placement in placements" :key="placement" :delay="0">
    <Button variant="secondary">{{ placement }}</Button>
    <TooltipContent :placement>
      <TooltipArrow />
      Placed {{ placement }}
    </TooltipContent>
  </Tooltip>
</template>

TooltipArrow is optional and points back at the trigger from whichever side the tooltip ended up on.

Delay ​

delay is how long a pointer has to rest before the tooltip opens, and close-delay is how long it stays after the pointer leaves. The delay is what stops a row of icon buttons flashing tooltips as the pointer crosses them; set it to 0 only for a single control that is being demonstrated.

What not to put in one ​

  • Nothing interactive. A tooltip closes when the pointer leaves the trigger, so a link or button inside it cannot reliably be reached. Use a Dropdown or a Modal.
  • Nothing essential. If the reader has to know it to proceed, it belongs on the page.
  • Not a name that is already there. A tooltip repeating a visible label adds noise for someone using a screen reader, who hears both.

Accessibility ​

  • A trigger with no visible text still needs an aria-label. The tooltip describes the control; it does not name it.
  • Focusing the trigger opens the tooltip, so a keyboard reader gets what a pointer reader gets.
  • Esc closes it without moving focus.

API ​

Tooltip

PropTypeDefaultDescription
closeDelaynumberthe `--rp-tooltip-close-delay` custom property, or 500How long the tooltip stays after the pointer leaves.
defaultOpenboolean—
delaynumberthe `--rp-tooltip-delay` custom property, or 1500How long the pointer has to rest on the trigger before the tooltip opens.
isDisabledboolean—
isOpenboolean—
shouldCloseOnPressbooleantrueWhether pressing the trigger closes the tooltip.
shouldSkipAnimationbooleanfalseWhether a tooltip replacing another one appears without an animation. Off by default, which is a deliberate difference from React Aria: it skips both animations while its shared warmup timer is running, whereas here the fade is driven from the stylesheet and is what makes a swap read as one label moving rather than two flashing.
trigger"focus" | "hover""hover"Opens on hover and on keyboard focus, or on focus alone.

Slots: default.

EventPayload
openChangeboolean
update:isOpenboolean

TooltipArrow

Slots: default.

TooltipContent

PropTypeDefaultDescription
arrowBoundaryOffsetnumber0Distance kept between the arrow and the corner of the tooltip.
containerPaddingnumber12Distance kept between the tooltip and the edge of the viewport.
crossOffsetnumber0Distance along the cross axis.
isEnteringboolean—Forces the entry state, for a caller driving the animation itself.
isExitingboolean—Forces the exit state.
offsetnumber7 with an arrow, 3 withoutDistance along the main axis, between the tooltip and its trigger.
placement"bottom" | "bottom end" | "bottom left" | "bottom right" | "bottom start" | "end" | "end bottom" | "end top" | "left" | "left bottom" | "left top" | "right" | "right bottom" | "right top" | "start" | "start bottom" | "start top" | "top" | "top end" | "top left" | "top right" | "top start""top"Where the tooltip sits relative to its trigger.
portalContainerstring | HTMLElementdocument.bodyWhere the tooltip is rendered.
shouldFlipbooleantrueWhether the tooltip may flip to the other side when it does not fit.
showArrowbooleanfalseWhether the tooltip leaves room for an arrow. Only the offset: the arrow itself is rendered by TooltipArrow, so setting this without one simply spaces the tooltip further from its trigger.

Slots: default.

TooltipTrigger

Slots: default.