Updated
Anagram Shuffle
LISTEN
Customize
Duration0.45s
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/anagram-shuffle.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/anagram-shuffle/anagram-shuffle.tsx"use client"; import { cn } from "@/lib/utils"; import { motion } from "motion/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; // The entry for the nth press, wrapping around the list. const pick = <T,>(list: T[], play: number) => list[((play % list.length) + list.length) % list.length]; // 08 — The same six letters rearrange into a new word. Each letter keeps its // identity and glides to its new slot. const ANAGRAMS = ["LISTEN", "SILENT", "ENLIST", "TINSEL"];
Adds the files to
components/uibrik/anagram-shuffle and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/anagram-shuffle.Usage
import { AnagramShuffle } from "@/components/uibrik/anagram-shuffle/anagram-shuffle";<AnagramShuffle play={0} words={["LISTEN", "SILENT", "ENLIST", "TINSEL"]} duration={0.45}/>Where to use Anagram Shuffle
Rotating hero headlines
Letters rearrange into the next phrase in place, so a headline can cycle through benefits without a jump in layout.
Pairs with Rolling Word
Personal portfolios
Shuffling a name into a role, or one title into another, makes a short intro memorable with nothing but type.
Word and puzzle games
Letters physically moving between words suits splash screens and level transitions for word games.
Props
AnagramShuffle- words
- Type string[]
- ["LISTEN","SILENT","ENLIST","TINSEL"]
- Anagrams of each other, cycled one per play.
- duration
- Type number
- 0.45
- Time for letters to glide to their new slots.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.