Variable Font Cursor Proximity
fancy/variable-font-cursor-proximityFreeComponent
A ui component.
Install it
npx shadcn@latest add https://www.fancycomponents.dev/r/variable-font-cursor-proximity.jsonSource
1"use client"23import React, { ElementType, forwardRef, useMemo, useRef } from "react"4import { motion, useAnimationFrame } from "motion/react"56import { cn } from "@/lib/utils"7import { useMousePositionRef } from "@/hooks/use-mouse-position-ref"89/**10 * Props for the VariableFontCursorProximity component.11 */12interface TextProps extends React.HTMLAttributes<HTMLElement> {13 /**14 * The text content to display and animate.15 * Each letter will respond individually to cursor proximity.16 * Required prop with no default value.17 */18 children: React.ReactNode1920 /**21 * HTML Tag to render the component as.22 * @default "span"23 */24 as?: ElementType2526 /**27 * Default font variation settings applied when cursor is outside the radius.28 * Should be a CSS font-variation-settings string (e.g., "'wght' 400, 'slnt' 0").29 * You should check the font variation settings of the font you are using to see the available axes.30 * Required prop with no default value.31 */32 fromFontVariationSettings: string3334 /**35 * Target font variation settings applied when cursor is at the center of a letter.36 * Should be a CSS font-variation-settings string (e.g., "'wght' 900, 'slnt' 15").37 * Make sure to check the font variation settings of the font you are using to see the available axes.38 * Required prop with no default value.39 */40 toFontVariationSettings: string4142 /**43 * Reference to the container element for mouse tracking.44 * The cursor position will be calculated relative to this container's bounds.45 * Required prop with no default value.46 */47 containerRef: React.RefObject<HTMLDivElement | null>4849 /**50 * The radius in pixels within which letters respond to cursor proximity.51 * Letters outside this radius will use the default font variation settings.52 * @default 5053 */54 radius?: number5556 /**57 * The falloff function that determines how the effect diminishes with distance.58 * - "linear": Linear interpolation (straight line falloff)59 * - "exponential": Quadratic falloff (more dramatic near cursor)60 * - "gaussian": Bell curve falloff (smooth, natural feeling)61 * @default "linear"62 */63 falloff?: "linear" | "exponential" | "gaussian"64}6566const VariableFontCursorProximity = forwardRef<HTMLElement, TextProps>(67 (68 {69 children,70 as = "span",71 fromFontVariationSettings,72 toFontVariationSettings,73 containerRef,74 radius = 50,75 falloff = "linear",76 className,77 ...props78 },79 ref80// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from fancy
All 158 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradient With Svganimated-gradient-with-svg | fancy | Components | Free | no deps | |
| Basic Number Tickerbasic-number-ticker | fancy | Components | Free | 1 dep | |
| Box Carouselbox-carousel | fancy | Components | Free | 1 dep | |
| Breathing Textbreathing-text | fancy | Components | Free | 1 dep | |
| Circling Elementscircling-elements | fancy | Components | Free | 1 dep | |
| Css Boxcss-box | fancy | Components | Free | 1 dep | |
| Cursor Attractor And Gravitycursor-attractor-and-gravity | fancy | Components | Free | 5 deps | |
| Drag Elementsdrag-elements | fancy | Components | Free | 1 dep |
