Skip to content
Effects Fancy Stable

SmoothCursor

.md

Multiplayer-style cursor: an upright coloured arrow with a white rim follows the pointer on a spring, and a name pill trails it on a softer spring and dims when idle.

Available for Svelte 5, React, and Vue 3.

Preview

Installation

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

Usage

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

	// Scope the cursor to this canvas: it mounts while the pointer is inside
	// and the native cursor comes back as soon as it leaves.
	let inside = $state(false);
</script>

<div
	class="w-full rounded-2xl border border-black/[0.08] bg-[#f4f4f5] p-1.5 dark:border-white/[0.08] dark:bg-[#0b0b0c]"
>
	<div
		role="presentation"
		class="relative flex h-72 cursor-none items-center justify-center overflow-hidden rounded-xl border border-black/[0.08] bg-[#fafafa] bg-[radial-gradient(rgba(0,0,0,0.09)_1px,transparent_1px)] [background-size:18px_18px] dark:border-white/[0.08] dark:bg-[#141416] dark:bg-[radial-gradient(rgba(255,255,255,0.07)_1px,transparent_1px)]"
		onpointerenter={() => (inside = true)}
		onpointerleave={() => (inside = false)}
	>
		<div class="flex flex-col items-center gap-2 select-none">
			<span
				class="rounded-full border border-black/[0.08] bg-white px-3 py-1 text-xs text-neutral-500 shadow-sm dark:border-white/[0.08] dark:bg-white/[0.04] dark:text-neutral-400"
			>
				Move your pointer here
			</span>
			<span class="text-[11px] text-neutral-400 dark:text-neutral-500">
				Rest for a moment and the name pill dims
			</span>
		</div>
	</div>
</div>

{#if inside}
	<SmoothCursor label="You" />
{/if}

Examples

Basic Usage

A "You" cursor limited to a nested-frame canvas. Rest a moment and the name pill dims.

Multiplayer Canvas

Your live blue cursor joins two static teammates on a shared canvas, each with a name pill in their own colour.

Props

PropTypeDefaultDescription
springConfig SpringConfig{}Spring physics configuration with damping, stiffness, and mass
label stringundefinedName shown in a pill that trails the arrow on its own softer spring. No pill when omitted.
color string"#0e9f6e"Fill colour of the arrow and the name pill (any CSS colour). Can also be overridden from a class with --smooth-cursor-color.
rotate booleanfalseRotate the cursor toward its direction of travel (pivoting on its centre). When false, the arrow stays upright with its tip as the hotspot.
idleFade number1500Milliseconds without pointer movement before the name pill dims to 35% opacity; 0 disables it.
labelSpring SpringConfigderivedSpring for the name pill. Missing fields derive from springConfig (stiffness × 0.55, damping × 1.1, same mass).

Slots

SlotDescription
cursor Custom cursor element (replaces the default arrow; the name pill still renders when label is set)