Components
Loading preview...
Dependency-free text-roll animation for tiny, tactile UI labels. Each character sits in its own clipped cell and slides to its new glyph with a springy overshoot — the new glyph enters from one side while the old slides out the other, chasing it by a stagger step. Pure CSS transforms, GPU-composited. Thin React wrapper over the slot-text package (npm i slot-text); supports direction, stagger, bounce and a chromatic color sweep.
@DanielWhit21874
npx shadcn@latest add https://21st.dev/r/DanielWhit21874/slot-text"use client"
import { useEffect, useState } from "react"
import { SlotText } from "@/components/ui/slot-text"
export default function SlotTextCounter() {
const [value, setValue] = useState(12480)
useEffect(() => {
const id = setInterval(() => {
setValue((v) => {
const next = v + Math.floor(Math.random() * 240) - 110
return Math.min(13200, Math.max(11800, next))
})
}, 1200)
return () => clearInterval(id)
}, [])
return (
<div className="flex min-h-[220px] w-full items-baseline justify-center gap-2">
<SlotText
text={value.toLocaleString("en-US")}
className="text-3xl font-semibold tabular-nums"
options={{ direction: "up", skipUnchanged: false }}
/>
<span className="text-sm text-muted-foreground">req/s</span>
</div>
)
}