Skip to content

Tooltip

Props

PropTypeDefaultOptionsDescription
triggerstring"hover"hover, clickOpen on hover (and on anchor focus when showOnFocus is true) or toggle on click
showOnFocusbooleantrueWhen trigger is hover, keep the tooltip open while the anchor is focused. Set false for hover-only visibility (mouse leave hides it even if the field stays focused)
isSubtlebooleanfalseSubtle color scheme (light bg) vs high-contrast (dark bg)
sizestring"m"s, m, lControls padding, border-radius, typography, and arrow dimensions
positionstring"top"top, right, bottom, leftPreferred tooltip position (auto-flips if not enough space)
alignmentstring"center"start, center, endCross-axis placement of the bubble vs the anchor; the arrow still targets the anchor center and may sit off-center on the bubble when the viewport clamps position
offsetnumber4Distance (px) between anchor and tooltip
maxWidthstring"320px"Max width of the tooltip body (CSS value). Use an empty string to remove the cap
disabledbooleanfalsePrevents the tooltip from showing
openboolean | nullnullnull, true, falseManual override: null = use trigger (hover/focus or click), true = always open, false = always closed
showDelaynumber100Delay (ms) before showing on hover
hideDelaynumber100Delay (ms) before hiding after mouse leaves
testSelectorsobjectSee Test SelectorsOverride data-test attributes for testing

See Component API — Props.

Controlling open from Vue

The open prop is intentionally tri-state (null = follow hover/click, true / false = forced open or closed).

If you bind :open="someRef" in a Vue 3 template and toggle someRef from false back to null, the tooltip can stay forced closed even though you intended uncontrolled mode. That behaviour comes from Vue’s runtime DOM patching, not from Catnip: for custom-element hosts, patchDOMProp can coerce null / undefined to false once the host property is already typed as a boolean (for example after false was applied once). This is tracked upstream as vuejs/core#14209. A related change proposal is vuejs/core#14459 — check whether it is merged in the Vue version you ship before assuming reactive :open can express null again.

What works today

  • Set open on the host element from script (for example a template ref and watch) so you assign tooltipRef.value.open = null (or true / false) directly. That path reaches the Vue custom-element setter without the same coercion, so null correctly restores hover/click behaviour.
  • Plain attributes (setAttribute / removeAttribute) on <catnip-tooltip> are fine for HTML-only apps; with automatic type conversion enabled, Catnip avoids stripping those attributes when coercing string values to booleans.

For the broader pattern (any catnip-* prop that needs null on a boolean-typed host property), see Usage — Vue 3: nullish values on custom elements.

Slots

NameDescription
anchorTrigger (defaults to info icon). With a custom anchor, use a focusable control (<button>, <a href>, etc.); the wrapper does not add tabindex, so focus stays on that control.
defaultThe tooltip content.

See Component API — Slots.

Methods

MethodDescription
reposition()Manually recalculate tooltip position. Call after dynamic content changes (for example anchor resizes).
vue
<template>
  <catnip-tooltip ref="tooltipRef">…</catnip-tooltip>
</template>
<script setup>
const tooltipRef = ref(null);
onMounted(() => {
  // After layout change
  tooltipRef.value?.reposition?.();
});
</script>

Test Selectors

AttributeDefault Value
rootcatnip-tooltip
anchorcatnip-tooltip-anchor
contentcatnip-tooltip-content

See Component API — Test selectors.

Catnip Design System by Signicat