Updated
Hover Weight
Customize
Min weight400
Max weight700
Radius60px
Sweep0.9s
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/hover-weight.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/hover-weight/hover-weight.tsx"use client"; import { cn } from "@/lib/utils"; import { animate, motion, useMotionValue, useSpring, useTransform, type MotionValue } from "motion/react"; import { useEffect, useRef } from "react"; // `play` counts presses of a card's Change button. 0 means the card has not // been pressed yet, so every effect renders its resting state without // animating on page load. export type EffectProps = { play: number }; // Size comes from --text-effect-size (default 1.25rem, i.e. text-xl), so a // preview can enlarge every effect without changing the installed default. const SIZE = "text-[length:var(--text-effect-size,1.25rem)] leading-[1.4]"; const TEXT = `${SIZE} text-zinc-700 font-medium dark:text-zinc-200`; const glyph = (ch: string) => (ch === " " ? " " : ch); // 01 — Letters near the pointer grow bolder and settle back once it moves // on. Pressing Change sweeps a virtual pointer across the line. const AWAY = -9999; export function HoverWeight({
Adds the files to
components/uibrik/hover-weight and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/hover-weight.Usage
import { HoverWeight } from "@/components/uibrik/hover-weight/hover-weight";<HoverWeight play={0} text="Move closer" minWeight={400} maxWeight={700} radius={60} sweepDuration={0.9}/>Where to use Hover Weight
Interactive headlines
Letters growing heavier as the cursor nears make a title respond to the visitor.
Pairs with Pull Toward Cursor
Font showcases
Variable weight under the pointer demonstrates a typeface's full range.
Portfolio intros
A name that thickens under the cursor is a subtle, type-led interaction.
Props
HoverWeight- text
- Type string
- "Move closer"
- The copy to animate.
- minWeight
- Type number
- 400
- Weight away from the pointer.
- maxWeight
- Type number
- 700
- Weight right under the pointer.
- radius
- Type number
- 60
- Reach of the pointer.
- sweepDuration
- Type number
- 0.9
- Replay sweep across the line.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.