Interactive text where font weight changes based on mouse proximity to each letter.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- react
- framer-motion
Code
'use client';
import { useRef } from 'react';
import { VariableProximityText } from '@/components/ui/variable-proximity-text';
export default function VariableProximityDemo() {
const containerRef = useRef<HTMLDivElement>(null);
return (
<>
{/* Load Roboto Flex variable font */}
<link
href="https://fonts.googleapis.com/css2?family=Roboto+Flex:opsz,wght@8..144,100..1000&display=swap"
rel="stylesheet"
/>
<div
ref={containerRef}
className="relative flex min-h-[300px] w-full items-center justify-center p-8"
>
<p className="text-4xl md:text-6xl">
<VariableProximityText
label="Hover over me!"
fromFontVariationSettings="'wght' 400, 'opsz' 9"
toFontVariationSettings="'wght' 900, 'opsz' 40"
containerRef={containerRef}
radius={100}
falloff="linear"
/>
</p>
</div>
</>
);
}
































