Skip to content
Overlays Core Stable

HoverCard

.md

An anchored panel that opens on hover or focus with a short delay, for richer previews than a tooltip — a profile card, a link preview

Available for Svelte 5, React, and Vue 3.

Preview

Installation

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

Usage

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

<HoverCard>
	{#snippet trigger(describedBy)}
		<button
			type="button"
			aria-describedby={describedBy}
			class="text-[13px] font-medium text-violet-300 hover:underline"
		>
			@alexrivera
		</button>
	{/snippet}
	{#snippet children()}
		<div class="flex items-center gap-2.5">
			<span class="h-9 w-9 flex-none rounded-full bg-gradient-to-br from-violet-500 to-sky-400"
			></span>
			<div class="flex flex-col">
				<span class="text-[13px] font-semibold">Alex Rivera</span>
				<span class="text-muted-foreground text-[11px]">@alexrivera</span>
			</div>
		</div>
		<p class="text-muted-foreground text-[12px] leading-relaxed">
			Frontend engineer. Building accessible interfaces, one component at a time.
		</p>
	{/snippet}
</HoverCard>

Examples

Basic Usage

A profile preview that opens on hover or focus.

With Stats

A richer card with a stats row, anchored above the trigger.

Props

PropTypeDefaultDescription
open booleanfalseWhether the card is open. Bindable
onOpenChange (open: boolean) => void-Fires whenever the open state changes, from any trigger
side "top" | "bottom" | "left" | "right""bottom"Side of the trigger the card opens on. Flips when it would overflow
align "start" | "center" | "end""center"Alignment along the trigger's cross axis
offset number8Gap in pixels between the trigger and the card
openDelay number300Ms before the card opens after the pointer enters the trigger. Ignored for focus, which opens immediately
closeDelay number150Ms before the card closes after the pointer leaves. Lets it travel from the trigger to the card without the card vanishing mid-trip
class string-Additional classes for the card panel
ref HTMLDivElement | nullnullBindable reference to the trigger wrapper

Slots

SlotDescription
trigger The element that opens the card on hover or focus. Receives the card's id (or undefined while closed) — put it on your own trigger element's aria-describedby
children The card's content. Supplementary only — see the README before adding links or buttons