Skip to content
WANCRAFT

C.74Typography & Text

Glitch Text

A tasteful RGB-split glitch: colour channels jump out in clipped slices, capped at three bursts a second.

NewReactCSSTailwindbasic

Overview

Glitch Text renders real text with two aria-hidden copies in the split-channel colours sitting behind it. During a burst the copies jump sideways in random horizontal slices (clip-path: inset) while the main text jitters slightly, then everything snaps back. Bursts can run while the text is hovered or focused, continuously at random, or on a fixed interval. Offsets scale with the font size, and a hard flash cap means bursts never start less than a third of a second apart. Timers stop offscreen and in hidden tabs, and with reduced motion the effect is switched off.

01Installation

Method 01 · Registry

CLI verified

Uses the shadcn CLI in a project initialised with shadcn init. Installs the file to components/ui/glitch-text.tsx and adds its dependencies.

npx shadcn@latest add https://wancraft.my/r/glitch-text.json

Method 02 · Copy and paste

  1. 1. No extra dependencies — React and Tailwind CSS only.
  2. 2. Copy the source from the Code tab into components/ui/glitch-text.tsx.
  3. 3. Import it and adjust props.
Dependencies
None
Peer
react ≥ 18, tailwindcss ≥ 4
Added
13 Oct 2026
Updated
—

02Usage

The default configuration. Change properties above to generate a tailored example in the Usage tab.

example.tsx
import { GlitchText } from "@/components/ui/glitch-text";

export function GlitchTextExample() {
  return (
    <GlitchText as="h2" className="text-5xl font-semibold tracking-tight" />
  );
}

03Props

PropTypeDefaultDescription
textstring"Signal lost"The text to render.
as"span" | "p" | "h1" | "h2" | "h3" | "div""span"Element to render.
intensitynumber0.5Strength of the channel offsets and slice heights, 0–1.
trigger"hover" | "always" | "interval""hover"Hover also responds to keyboard focus of the element or of an enclosing link/button.
colorAstring"#FF7448"First split channel, shifted left.
colorBstring"#2BB3C0"Second split channel, shifted right.
durationnumber420Length of one burst, in ms.
intervalnumber2400Time between bursts for the interval trigger, in ms (clamped to at least 334ms).
...propsHTMLAttributes—Forwarded to the root element.

04Features

  • 01RGB split via two channel-coloured copies behind the real text
  • 02Random horizontal slices with clip-path: inset() and sideways jumps
  • 03Hover/focus, always and interval triggers
  • 04Offsets scale with font size
  • 05Flash cap: at most three bursts per second, enforced in code
  • 06Timers stop offscreen and in hidden tabs
motion · continuousinput · hoverinput · focusinput · viewport

05Accessibility

  • The real text is rendered once and read normally; both channel copies are aria-hidden and unselectable.
  • Photosensitivity: bursts never start less than 334ms apart (≤ 3 per second, the WCAG 2.3.1 threshold), slices only cover thin bands of the glyphs, and there is no full-area colour inversion.
  • With prefers-reduced-motion the glitch is disabled completely and the text is static.
  • The hover trigger also fires on keyboard focus — of the element itself, or of the link or button it sits inside.

06Limitations

  • Use it for short display text; on paragraphs the effect is noisy and hurts reading.
  • The channel copies sit behind the text, so they are only visible where they stick out — on very light or very dark text colours pick channel colours with enough contrast against the page.