Skip to content

Tooltip

A simple and accessible tooltip. Hover, focus, and keyboard friendly.

Demo

Basic

Profile

Replaced content (image / wrap)

Tooltip is on the parent span; tabindex="0" enables keyboard focus.


Placement


Custom content slot


No arrow

Set :has-arrow="false" to use a box-only tooltip without a caret.


Install

bash
npm i @vuesimple/vs-tooltip

Usage

html
<template>
  <vs-tooltip title="Save your changes">
    <button type="button">Save</button>
  </vs-tooltip>
</template>

<script>
  import VsTooltip from '@vuesimple/vs-tooltip';

  export default {
    components: {
      VsTooltip,
    },
  };
</script>

CDN

html
<script src="https://cdn.jsdelivr.net/npm/@vuesimple/vs-tooltip@<version>/dist/index.min.js"></script>

TIP

Replace <version> with a version number in the above url.

javascript
// Main/Entry file
app.use(VsTooltipPlugin);
html
<template>
  <vs-tooltip title="Save your changes">
    <button type="button">Save</button>
  </vs-tooltip>
</template>

TIP

  • The panel is teleported to body. Set theme CSS variables on :root or html (or use inline style on the component) if you need tokens to apply to the floating layer.

Props

NameTypeDefaultDescription
titleString''Text when the content slot is not used.
placementStringtopPreferred side: top, bottom, left, right (may flip in viewport)
offsetNumber8Gap in px between anchor and panel.
openDelayNumber0ms after pointer enter before open.
closeDelayNumber100ms after leave/blur before close.
dismissibleBooleantrueEscape closes the tooltip.
zIndexNumber1080Stacking for the fixed teleported panel.
disabledBooleanfalseDisables show/hide.
hasArrowBooleantruefalse hides the pointer triangle on the panel.
tabindexString / NumbernullOn the anchor when the slot has no focusable child; use 0 for e.g. images

Slots

NameDescription
(default)The trigger; prefer a single focusable element for keyboard/screen reader users.
contentCustom tooltip body; overrides the title string.

Theming (CSS variables)

The component exposes design tokens (see the package SFC) such as:

VariableRole
--vs-tooltip-bg-lightDefault surface in light app theme
--vs-tooltip-bg-darkSurface when data-theme is dark
--vs-tooltip-padding-lightDefault padding
--vs-tooltip-padding-darkPadding in dark app theme
--vs-tooltip-arrowCaret / border size
--vs-tooltip-radiusPanel corner radius
--vs-tooltip-shadowbox-shadow for the panel

Set these on :root or .vs-tooltip__panel or another ancestor of the teleported body content so the floating panel can resolve them.

Accessibility

  • Uses role="tooltip" and links the trigger to the panel with aria-describedby on the actual focusable node.
  • pointer-events: none on the floating label so the pattern stays non-interactive (supplementary text).
  • Dismiss with Escape when dismissible is true; respects prefers-reduced-motion for transitions.