Glitch Text .mv-glitch-text

Glitch RGB en CSS puro: finas bandas magenta y cian del texto saltan de lado en ráfagas breves, de forma continua o al pasar el puntero, con un límite por debajo de tres destellos por segundo.

CategoríaTexto animado
TipoCSS puro (.mv-glitch-text)
Estadoestable
Keywordsglitch, rgb-split, cyberpunk, 404, error, retro, hover

When to use

  • A 404, error or cyberpunk-styled heading needs an RGB-split digital glitch
  • A link or button label should glitch only on hover or keyboard focus
  • A text effect must work without JavaScript and stay safe for photosensitive visitors

Avoid when

  • Large areas or body copy would glitch permanently; the motion hurts readability and comfort
  • The text should resolve once from random glyphs into the real text → use Scramble Text instead

Instalación

node scripts/add.mjs glitch-text --out ./src/marvelous

Agente de IA con el servidor MCP de Marvelous UI: install_components({ slugs: ["glitch-text"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Archivos copiados (dependencias incluidas): tokens/tokens.css, core/base.css, components/glitch-text/glitch-text.css.

Uso

Marcado de referencia: parte de él y personalízalo con atributos, data-* y variables CSS:

<div style="display:grid;gap:1.5rem;justify-items:center;text-align:center">
  <p style="margin:0;font:800 clamp(3rem,9vw,5.5rem)/1 var(--mv-font-mono);letter-spacing:-.04em">
    <span class="mv-glitch-text" data-text="404">404</span>
  </p>
  <p style="margin:0;font:600 clamp(1.1rem,2.4vw,1.4rem)/1.2 var(--mv-font-mono);text-transform:uppercase;letter-spacing:.18em;color:var(--mv-fg-muted)">
    <span class="mv-glitch-text" data-text="Signal lost" data-variant="constant" style="--mv-glitch-text-intensity:.6">Signal lost</span>
  </p>
  <div style="display:flex;gap:1.25rem;flex-wrap:wrap;justify-content:center;align-items:center;margin-top:.5rem">
    <a class="mv-button" data-variant="outline" href="#" style="font-family:var(--mv-font-mono)">
      <span class="mv-glitch-text" data-text="Reconnect" data-trigger="hover" style="--mv-glitch-text-intensity:1.6">Reconnect</span>
    </a>
    <span class="mv-glitch-text" data-text="Uplink unstable" style="font:700 .9rem var(--mv-font-mono);text-transform:uppercase;letter-spacing:.12em;color:var(--mv-danger);--mv-glitch-text-intensity:2.2;--mv-glitch-text-duration:2.4s">Uplink unstable</span>
  </div>
</div>

API

Attributes

NameTipoDescription
data-textstringRequired: same text as the content (the decorative copies are built from it).
data-triggerhoverAt rest until hovered (hover-capable pointers) or keyboard-focused, on the element or on a surrounding link, button or label.
data-variantconstantSteady stream of bands with no calm phase.

CSS classes

NameDescription
mv-glitch-textOn a span / heading. Copy the text into data-text (the decorative copies come from it).

CSS variables

NameDefaultDescription
--mv-glitch-text-intensity1Sideways shift amplitude (0 = bands stay aligned).
--mv-glitch-text-duration3.2s (constant: 2s)Length of one cycle. Floored at 2.4s (constant: 1.5s) to stay under the flash limit.
--mv-glitch-text-color-1magentaColor of the band shifted left.
--mv-glitch-text-color-2cyanColor of the band shifted right.

Accessibility

The real text is read once: the two copies are ::before/::after pseudo-elements with empty alt text (content: attr(data-text) / ""), so screen readers skip them, and they ignore the pointer. Visible changes are stepped and never exceed 4 per second (2 flashes), under the WCAG 2.3.1 limit of 3, and durations have a floor. Reduced motion: static text with a faint fixed RGB split. Forced colors: plain system text. The hover trigger also fires on keyboard focus and ignores touch hover.

Esta página se tradujo con IA. Informar de un problema de traducción