Updated
Scramble to Word
Customize
Cells8
Tick40ms
Lead6
Step2
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/scramble-to-word.jsonAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/scramble-to-word/scramble-to-word.tsx"use client"; import { cn } from "@/lib/utils"; import { useEffect, 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]"; // 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]; // 09 — A departures board without the flip: every cell scrambles through // random characters, then the cells lock in order, left to right, so the // new word sorts itself out of the noise. const SCRAMBLE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; const FLAP_WORDS = ["BOARDING", "GATE 21", "ON TIME", "DEPARTED"]; const randomChar = () => SCRAMBLE_CHARS[Math.floor(Math.random() * SCRAMBLE_CHARS.length)];
Adds the files to
components/uibrik/scramble-to-word. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/scramble-to-word.Usage
import { ScrambleToWord } from "@/components/uibrik/scramble-to-word/scramble-to-word";<ScrambleToWord play={0} words={["BOARDING", "GATE 21", "ON TIME", "DEPARTED"]} cells={8} tick={40} lead={6} step={2}/>Where to use Scramble to Word
Departure-board headlines
A split-flap board scrambling to the next word evokes stations and airports.
Travel brands
The board fits booking, transport and travel products.
Pairs with Swap Fields
Rotating taglines
Each flip reveals a new benefit with a familiar, readable effect.
Pairs with Rolling Word
Props
ScrambleToWord- words
- Type string[]
- ["BOARDING","GATE 21","ON TIME","DEPARTED"]
- Cycled through, one per play.
- cells
- Type number
- 8
- Number of cells on the board.
- tick
- Type number
- 40
- Time between scramble frames.
- lead
- Type number
- 6
- Frames of noise before the first cell locks.
- step
- Type number
- 2
- Frames between cells locking.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.