Skip to content
Overlays Core Stable

Tooltip

.md

A small anchored label that explains a control on hover or focus — plain text only, never interactive content

Available for Svelte 5, React, and Vue 3.

Preview

Installation

pnpm add fancy-ui-svelte
import { Tooltip } from "fancy-ui-svelte";

Usage

svelte
<script lang="ts">
	import { Tooltip } from "fancy-ui-svelte";
	import { IconButton } from "fancy-ui-svelte";

	let liked = $state(false);
</script>

<Tooltip content={liked ? "Remove from favorites" : "Add to favorites"}>
	<IconButton
		label={liked ? "Remove from favorites" : "Add to favorites"}
		variant="outline"
		onclick={() => (liked = !liked)}
	>
		<svg
			class="size-4"
			viewBox="0 0 24 24"
			fill={liked ? "currentColor" : "none"}
			stroke="currentColor"
			stroke-width="2"
			stroke-linecap="round"
			stroke-linejoin="round"
			aria-hidden="true"
		>
			<path
				d="M12 20s-7-4.35-9.5-9A5.5 5.5 0 0 1 12 6a5.5 5.5 0 0 1 9.5 5c-2.5 4.65-9.5 9-9.5 9Z"
			/>
		</svg>
	</IconButton>
</Tooltip>

Examples

Basic Usage

A heart IconButton with a tooltip, matching the mockup.

Sides

The tooltip placed on each of the four sides.

Delays

openDelay and closeDelay tuned away from their defaults.

Props

PropTypeDefaultDescription
content *string-The tooltip's text
side "top" | "bottom" | "left" | "right""top"Side of the trigger to place the tooltip on
align "start" | "center" | "end""center"Alignment along the trigger's cross axis
offset number6Gap in pixels between the trigger and the tooltip
openDelay number500Delay in ms before a hover opens it. Never applied to a focus open
closeDelay number0Delay in ms before it closes once neither hovered nor focused
disabled booleanfalseSuppresses it entirely — no open on hover or focus
class string-Additional CSS classes, merged onto the trigger wrapper
ref HTMLElement | nullnullBindable reference to the trigger wrapper element

Slots

SlotDescription
children The trigger. Must render exactly one focusable element — a button, link, or similar