Updated
Slot-machine Letters
Customize
Duration0.50s
Stagger0.05s
Text size48px
Installation
npx shadcn@latest add https://uibrik.com/r/slot-letters.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/slot-letters/slot-letters.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]; // 10 — Letters roll on vertical reels like an odometer and stop on the next // word, each reel a beat after the one before it. const REEL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Adds the files to
components/uibrik/slot-letters and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/slot-letters.Usage
import { SlotLetters } from "@/components/uibrik/slot-letters/slot-letters";<SlotLetters play={0} words={["ROUND", "ABOUT", "TURNS", "AGAIN"]} duration={0.5} stagger={0.05}/>Where to use Slot-machine Letters
Rotating headlines
Each letter spinning like a reel to land on the next word adds suspense.
Pairs with Scramble to Word
Casino and game themes
Slot-machine letters fit games, prizes and lotteries.
Reveals and countdowns
Landing on a word works for announcing a winner or launch name.
Props
SlotLetters- words
- Type string[]
- ["ROUND","ABOUT","TURNS","AGAIN"]
- Uppercase A–Z words, cycled one per play.
- duration
- Type number
- 0.5
- Time for a reel to stop.
- stagger
- Type number
- 0.05
- Delay between reels.
- playrequired
- Type number
- –
- Each change plays the effect again; 0 shows its resting state.