Skip to content

useMouseVars

Feeds cursor-coordinate CSS variables to an element, powering effects.css's .lx-spot (cursor spotlight) and .lx-tilt (3D micro-tilt).

Usage

光标跟随卡片移动光标:spotlight 跟随 + 3D 微倾斜(≤±7°)

API

useMouseVars(target: Ref<HTMLElement | null>, opts?: { tilt?: boolean; maxTilt?: number }): void

ParamDefaultDescription
targettarget element ref
opts.tiltfalseemit tilt-angle variables
opts.maxTilt7max tilt (degrees)

Emitted CSS variables:

VariableDescription
--lx-mx / --lx-mycursor position inside the element (for .lx-spot)
--lx-rx / --lx-rytilt angles (with tilt: true; reset on leave)

Behavior & boundaries: SSR-safe (binds in onMounted only); no tilt output under prefers-reduced-motion: reduce.