About
An expressive React button with character-by-character text scrambling, progressive reveals, customizable animation timing, three visual variants, and hover or click triggers.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Text Scramble Button to your project and fits it to your theme.
Code
How Text Scramble Button is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
/**
* TextScrambleButton — Interactive Demo
*
* Shows all three variants, all three trigger modes, custom text,
* Unicode labels, and all configurable props in a single interactive preview.
*/
"use client";
import React, { useState } from "react";
import TextScrambleButton from "@/components/ui/text-scramble-button";
import type { ScrambleTrigger, ScrambleVariant } from "@/components/ui/text-scramble-button";
// ─── Sample texts to try ──────────────────────────────────────────────────────
const SAMPLE_TEXTS = [
"Encrypt Data",
"Launch →",
"日本語テスト",
"v2.0 (Beta!)",
"Get Started",
"Subscribe Now",
];
// ─── Minimal inline styles ────────────────────────────────────────────────────
const page: React.CSSProperties = {
minHeight: "100vh",
background: "#0a0a0f",
color: "#e4e4e7",
fontFamily:
"Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: "56px",
padding: "48px 24px",
};
const section: React.CSSProperties = {
display: "flex",
flexDirection: "column",
alignItems: "center",
gap: "12px",
width: "100%",
maxWidth: "600px",
};
const heading: React.CSSProperties = {
fontSize: "11px",
fontWeight: 600,
letterSpacing: "0.08em",
textTransform: "uppercase",
color: "#52525b",
marginBottom: "8px",
};
const row: React.CSSProperties = {
display: "flex",
flexWrap: "wrap",
gap: "12px",
justifyContent: "center",
alignItems: "center",
};
const pill: React.CSSProperties = {
padding: "6px 14px",
fontSize: "12px",
fontWeight: 500,
borderRadius: "6px",
border: "1px solid rgba(255,255,255,0.08)",
background: "transparent",
color: "#71717a",
cursor: "pointer",
fontFamily: "inherit",
transition: "all 0.15s",
};
const pillActive: React.CSSProperties = {
...pill,
background: "rgba(124,138,255,0.14)",
border: "1px solid rgba(124,138,255,0.4)",
color: "#e4e4e7",
fontWeight: 600,
};
// ─── Demo ─────────────────────────────────────────────────────────────────────
export default function Demo() {
const [text, setText] = useState("Encrypt Data");
const [customText, setCustomText] = useState("");
const [trigger, setTrigger] = useState<ScrambleTrigger>("hover");
const [variant, setVariant] = useState<ScrambleVariant>("default");
const [duration, setDuration] = useState(600);
const displayText = customText.trim() || text;
return (
<div style={page}>
{/* ── Hero: single configurable button ── */}
<div style={section}>
<div style={heading}>Live Preview</div>
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
minHeight: "120px",
width: "100%",
border: "1px solid rgba(255,255,255,0.06)",
borderRadius: "16px",
background:
"radial-gradient(circle at center, rgba(124,138,255,0.04) 0%, transparent 70%)",
}}
>
<TextScrambleButton
text={displayText}
trigger={trigger}
variant={variant}
duration={duration}
/>
</div>
{/* text presets */}
<div style={{ display: "flex", gap: "6px", flexWrap: "wrap", justifyContent: "center" }}>
{SAMPLE_TEXTS.map((t) => (
<button
key={t}
style={text === t && !customText ? pillActive : pill}
onClick={() => { setText(t); setCustomText(""); }}
>
{t}
</button>
))}
</div>
{/* custom text input */}
<input
type="text"
value={customText}
onChange={(e) => setCustomText(e.target.value)}
placeholder="Type custom text…"
style={{
width: "100%",
maxWidth: "340px",
background: "rgba(255,255,255,0.04)",
border: "1px solid rgba(255,255,255,0.08)",
borderRadius: "8px",
padding: "9px 14px",
fontSize: "13px",
color: "#e4e4e7",
fontFamily: "'SF Mono', 'Fira Code', monospace",
outline: "none",
}}
/>
</div>
{/* ── Trigger selector ── */}
<div style={section}>
<div style={heading}>Trigger</div>
<div style={row}>
{(["hover", "click", "both"] as ScrambleTrigger[]).map((t) => (
<button
key={t}
style={trigger === t ? pillActive : pill}
onClick={() => setTrigger(t)}
>
{t}
</button>
))}
</div>
</div>
{/* ── All three variants, side by side ── */}
<div style={section}>
<div style={heading}>Variants</div>
<div style={row}>
<TextScrambleButton text="Default" variant="default" trigger="hover" />
<TextScrambleButton text="Playful" variant="playful" trigger="hover" />
<TextScrambleButton text="Minimal" variant="minimal" trigger="hover" />
</div>
<div style={{ display: "flex", gap: "8px", marginTop: "4px" }}>
{(["default", "playful", "minimal"] as ScrambleVariant[]).map((v) => (
<button
key={v}
style={variant === v ? pillActive : pill}
onClick={() => setVariant(v)}
>
{v}
</button>
))}
</div>
</div>
{/* ── Duration control ── */}
<div style={section}>
<div style={heading}>Duration — {duration}ms</div>
<input
type="range"
min={100}
max={2000}
step={50}
value={duration}
onChange={(e) => setDuration(Number(e.target.value))}
style={{ width: "240px", accentColor: "#7c8aff" }}
/>
</div>
{/* ── Disabled state ── */}
<div style={section}>
<div style={heading}>Disabled</div>
<div style={row}>
<TextScrambleButton text="Disabled" disabled variant="default" />
<TextScrambleButton text="Disabled" disabled variant="playful" />
<TextScrambleButton text="Disabled" disabled variant="minimal" />
</div>
</div>
{/* ── Unicode & special chars ── */}
<div style={section}>
<div style={heading}>Unicode & Special Characters</div>
<div style={row}>
<TextScrambleButton text="日本語" trigger="hover" />
<TextScrambleButton text="← Back" trigger="hover" />
<TextScrambleButton text="v2.0 (Beta!)" trigger="hover" />
</div>
</div>
</div>
);
}







