Baktiyar Ablaikhan

Encrypted Text

Source
Aceternity UI ↗
Author
Aceternity UI
Licence
Aceternity UI licence (free component)

Loading…

Scrambled characters resolve into the sentence one by one; hover to replay.

Code

"use client";
import { EncryptedText } from "@/lab/aceternity/ui/encrypted-text";
import React, { useState } from "react";
import { Fit } from "./_fit";

export default function EncryptedTextDemoSecond() {
  // Hovering the stage replays the decryption.
  const [run, setRun] = useState(0);
  return (
    <div className="h-full w-full" onPointerEnter={() => setRun((r) => r + 1)}>
      <Fit width={460} height={160} max={2}>
        <div className="flex h-full items-center justify-center">
          <p className="mx-auto max-w-lg text-left text-xl font-mono">
            <EncryptedText
              key={run}
              text="Welcome to the Matrix, Neo."
              encryptedClassName="text-neutral-500"
              revealedClassName="dark:text-white text-black"
              revealDelayMs={50}
            />
          </p>
        </div>
      </Fit>
    </div>
  );
}
Prompt

Build "Encrypted Text", a text animation. What it does: Scrambled characters resolve into the sentence one by one; hover to replay. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS, using motion. Technique: a requestAnimationFrame loop, the Motion library. It sits on a dark background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://ui.aceternity.com/components/encrypted-text (Aceternity UI, Aceternity UI licence (free component)).