1 estrella en GitHub = 1 componente nuevo.

Dar una estrella
Tipografía typographyglitchcyberpunk

Glitch Text

Texto con animación de distorsión glitch y aberración cromática estilo cyberpunk.

Vista Previa en Vivo

Uso

Copia y pega este código directamente en tu página de Astro:

astro
---
import { GlitchText } from 'astro-component-kit';
---

<CyberpunkGlitchText text="Sample text">Content</CyberpunkGlitchText>
--- import { GlitchText } from 'astro-component-kit'; --- <CyberpunkGlitchText text="Sample text">Content</CyberpunkGlitchText>

Instalación Manual

Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/lib/GlitchText.astro:

astro
---
interface Props { text: string; }
const { text } = Astro.props;
---
<div class="glitch-text" data-text={text}>{text}</div>
<style>
  .glitch-text { position: relative; font-size: 3rem; font-weight: 900; color: #fff; text-transform: uppercase; }
  .glitch-text::before, .glitch-text::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
  .glitch-text::before { left: 2px; text-shadow: -2px 0 #ff003c; clip: rect(44px, 450px, 56px, 0); animation: glitch-anim 5s infinite linear alternate-reverse; }
  .glitch-text::after { left: -2px; text-shadow: -2px 0 #00e0ff; clip: rect(12px, 450px, 80px, 0); animation: glitch-anim 2s infinite linear alternate-reverse; }
  @keyframes glitch-anim { 
    0% { clip: rect(10px, 9999px, 20px, 0); transform: skew(0.5deg); } 
    20% { clip: rect(40px, 9999px, 50px, 0); } 
    40% { clip: rect(80px, 9999px, 90px, 0); } 
    60% { clip: rect(20px, 9999px, 30px, 0); } 
    80% { clip: rect(60px, 9999px, 70px, 0); } 
    100% { clip: rect(0, 9999px, 10px, 0); transform: skew(-0.5deg); } 
  }
  @media (max-width: 768px) { .glitch-text { font-size: 2rem; } }
</style>
--- interface Props { text: string; } const { text } = Astro.props; --- <div class="glitch-text" data-text={text}>{text}</div> <style> .glitch-text { position: relative; font-size: 3rem; font-weight: 900; color: #fff; text-transform: uppercase; } .glitch-text::before, .glitch-text::after { content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .glitch-text::before { left: 2px; text-shadow: -2px 0 #ff003c; clip: rect(44px, 450px, 56px, 0); animation: glitch-anim 5s infinite linear alternate-reverse; } .glitch-text::after { left: -2px; text-shadow: -2px 0 #00e0ff; clip: rect(12px, 450px, 80px, 0); animation: glitch-anim 2s infinite linear alternate-reverse; } @keyframes glitch-anim { 0% { clip: rect(10px, 9999px, 20px, 0); transform: skew(0.5deg); } 20% { clip: rect(40px, 9999px, 50px, 0); } 40% { clip: rect(80px, 9999px, 90px, 0); } 60% { clip: rect(20px, 9999px, 30px, 0); } 80% { clip: rect(60px, 9999px, 70px, 0); } 100% { clip: rect(0, 9999px, 10px, 0); transform: skew(-0.5deg); } } @media (max-width: 768px) { .glitch-text { font-size: 2rem; } } </style>

Información Rápida

Categoría
Tipografía
Nombre de archivo
GlitchText.astro
Dependencias
Ninguna — Astro nativo + CSS puro
Etiquetas
typographyglitchcyberpunk