Hooks
useGlide
Lets hover marks glide from point to point and fade out in place, instead of jumping or vanishing.
Give it the active index (or ). keeps the last active point while the marks fade out, says whether they show, and is true for the one frame they appear, so they jump into place the first time and glide from then on. Pair it with , an SVG group that moves by a CSS transform on the token and the entrance curve.
See alsoLine ChartArea Chart
Import
import { useGlide } from "@wunderui/react/charts"Comes with WunderUI Core and Pro, in the entry of the package from your plan. See the plans.
Signature
useGlide(active: number | null): GlideParameters
Returns
Examples
A gliding hover dot in a custom SVG chart
import { GlideGroup, useGlide } from "@wunderui/react/charts"
function HoverDot({ active, points }: { active: number | null; points: { x: number; y: number }[] }) {
const glide = useGlide(active)
const p = points[glide.index ?? 0]
return (
<GlideGroup x={p.x} y={p.y} visible={glide.visible} snap={glide.snap}>
<circle r={5} fill="var(--chart-1)" className="stroke-card" strokeWidth={2} />
</GlideGroup>
)
}Notes
- Under reduced motion only fades; it does not move.
- Only and animate, so a gliding mark never causes layout work.
- Give the marks ; the chart's live region announces the active point.