Updated
Lean and Scramble
Customize
Lean10°
Duration0.45s
Word stagger0.08s
Scramble tick40ms
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/lean-scramble.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/lean-scramble/lean-scramble.tsx"use client"; import { cn } from "@/lib/utils"; import { motion, stagger, useAnimate } from "motion/react"; import { useCallback, useEffect, useRef, useState } 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 EASE_OUT = [0.23, 1, 0.32, 1] as const; // 02 — A word leans forward and scrambles as it goes: its letters cycle // through random characters and lock back in from left to right, finishing // as the word straightens. Pressing Change runs it word by word; hovering // runs it on one word. Every letter keeps its own width while scrambling, // so the line never jumps.
Adds the files to
components/uibrik/lean-scramble and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/lean-scramble.Usage
import { LeanScramble } from "@/components/uibrik/lean-scramble/lean-scramble";<LeanScramble play={0} text="Lean into every word" lean={10} duration={0.45} wordStagger={0.08} tick={40}/>Where to use Lean and Scramble
Interactive hero text
Words leaning and scrambling under the cursor give a headline a technical edge.
Pairs with Scramble Text
Hacker-style brands
Glitching letters suit security, crypto and developer products.
Portfolio intros
A name that scrambles on hover is a small, memorable interaction.
Props
LeanScramble- text
- Type string
- "Lean into every word"
- The copy to animate.
- lean
- Type number
- 10
- How far a word leans.
- duration
- Type number
- 0.45
- Lean and straighten time.
- wordStagger
- Type number
- 0.08
- Delay between words.
- tick
- Type number
- 40
- Time between scramble frames.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.