Pixel Text

Text built from pixels that reacts to the cursor. The real text stays in the DOM (SEO, screen readers, selection, copy). A canvas paints it and lifts only the pixels the cursor touches. Pixels are generated lazily per 128px tile near the cursor and only moving pixels are simulated, so cost does not grow with text length. Very tall text is windowed to the viewport. Honors prefers-reduced-motion.

Interactive Effect
Accent Color
Click Burst Force1

Pixel Text

Hover cursor over pixels to interact · Click for shockwave burst

Installation

  1. 1

    Install the component:

    npx shadcn@latest add https://ui.amines.fun/r/pixel-text.json
  2. 2

    Usage:

    jsx

    app/page.jsx

    import PixelText from "@/registry/components/Texts/Pixeltext";export default function Page() {  return (    <div className="flex min-h-[300px] items-center justify-center p-8">      <PixelText        as="h1"        variant="heading"        effect="repel"        accent="#FF7138"        className="text-6xl font-bold"      >        Pixel Text      </PixelText>    </div>  );}

Props

PropTypeDefaultDescription
textstring—Text content. Alternative to children.
childrenReactNode—Text content as children. Only string/number children are used.
as"h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span" | "div"—HTML tag to render. Defaults to h2 for heading variant, p for text variant.
variant"heading" | "text"headingPreset variant. Heading uses larger radius, stronger effect, streaks, and assemble intro. Text uses smaller radius, weaker effect, no streaks, and no intro.
effect"repel" | "attract" | "swirl" | "scatter" | "wave"repelCursor interaction effect. Repel pushes pixels away, attract pulls them, swirl rotates around cursor, scatter randomizes, wave creates sine motion.
radiusnumber—Cursor radius in pixels. Default varies by variant: ~1.8x font size for heading, ~3.6x for text.
strengthnumber—Displacement multiplier. Default: 1 for heading, 0.5 for text.
falloff"smooth" | "linear" | "sharp"smoothFalloff curve for cursor influence. Smooth is quadratic, linear is linear, sharp is cubic.
stiffnessnumber—Spring stiffness for pixel return. Default: 0.075 for heading, 0.1 for text.
dampingnumber—Spring damping (retention per frame). Lower = more friction. Default: 0.82 for heading, 0.8 for text.
chaosnumber1 (heading) / 0.6 (text)Per-pixel randomness 0..1. Higher = more organic variation.
pixelSizenumber | "auto"—Pixel size in pixels. Default: ~0.05x font for heading, ~0.09x for text. Use "auto" for automatic sizing.
pixelScalenumber0.92Pixel size relative to its grid cell (0.2 to 1.4).
shape"square" | "circle"squarePixel shape. Circles disable streaks.
colorstringcurrentColorText color. Any CSS color or CSS variable (e.g., "var(--color-main)").
accentstring—Moved pixels shift toward this color. Any CSS color or CSS variable.
streaksbooleantrue (heading) / false (text)Stretch pixels along their motion direction. Disabled for circles.
inertianumber1How much cursor speed drags pixels.
clickBurstboolean | number1 (heading) / 0.6 (text)Shockwave on click/tap. false disables, true uses preset, number sets intensity.
interactivebooleantrueEnable hover/touch reaction. false makes it static.
intro"assemble" | "none" | boolean"assemble" (heading) / "none" (text)Intro animation. "assemble" animates pixels into place, "none" shows immediately. true = assemble, false = none.
introFrom"scatter" | "top" | "bottom" | "left" | "right" | "center"scatterDirection pixels animate from during intro.
introOrder"ltr" | "rtl" | "ttb" | "btt" | "center" | "random"ltrOrder pixels animate in during intro.
introDurationnumber1100 (heading) / 700 (text)Intro animation duration in milliseconds.
introDelaynumber0Delay before intro starts in milliseconds.
introEasestring | number[] | functionoutCubicEasing for intro. Named: linear, outCubic, outExpo, inOutCubic, outBack, outElastic. Or cubic-bezier [x1,y1,x2,y2] or custom function (t)=>number.
introLimitnumber16000Max pixels the intro animates. Rest appear instantly.
bleednumber—Canvas extension past element in pixels. Default derived from radius.
maxDprnumber2Device pixel ratio cap.
maxParticlesnumber150000Cap on generated pixels.
respectReducedMotionbooleantrueDisable animations when prefers-reduced-motion is set.
onIntroEnd() => void—Callback fired when intro animation completes.
classNamestring—Additional CSS classes for the root element.
styleReact.CSSProperties—Inline styles for the root element.
...restReact.HTMLAttributes<HTMLElement>—Other native attributes (id, aria-*, data-*, etc.) passed to the root element.