GLITCH LAB v1.0 ezolab.dev / lab instrument SYS: READY โœฆ Holiday cards

Effects/ Glitch Button [FX_09]/ Calibrated

Glitch Button

Copies a link to this page with your text and settings โ€” whoever opens it sees the same effect. Send it to a friend, a colleague or save it for later.
Pure CSS Light ยท zero deps #button#cyberpunk#glitch

CSS glitch button hover effect: the button pixelates into bigger and bigger blocks with RGB noise and snaps back. CSS + SVG filters, no JS.

Live viewport Hover the previewTap the preview
LIVE FEED 60.0 FPS | FRAME: 16.7ms RES: โ€” [ + calibrated ]
Type any word: the preview changes at once, and so do the HTML you copy, the .zip and CodePen. Leave it empty to get the default word back.

How it works // breakdown

Spec-FX_09

This is a CSS glitch button hover effect that doesn't look like every other one: instead of the usual red and cyan slices, the button falls apart into bigger and bigger pixels โ€” 3, 5, 8, 12 px โ€” and gathers back, while bright red, green and blue specks of noise flash over the word. It's CSS plus four tiny SVG filters, no JavaScript. It works on a real <button> or a link and plays on hover and on keyboard focus. Below: how the pixelate filter works, the settings, and the traps.

Why this effect

I've seen hundreds of glitch buttons, and they're all the same two coloured slices sliding sideways. This one comes from my lab page: a picture that drops its resolution, like a video stream on a bad connection. It reads as "broken signal" instantly, but it's a different kind of broken โ€” chunky and digital, not torn. The colour specks are what sell it: on a screen with dead pixels, the noise is never grey.

What you'll build

A dark button with a light word and a thin border. Hover it, or tab to it with the keyboard, and for three quarters of a second it pixelates: fine cells first, then coarse blocks where the letters barely survive, then back to sharp. Pure R, G and B specks flash over the button at the same time, cover the word in places and turn into blocks along with it.

How the glitch button works

1. A pixelate filter in five SVG steps

CSS has no filter: pixelate(), but SVG filters can be used from CSS with filter: url(#id). One filter makes one cell size:

<filter id="gb-px8" x="0" y="0" width="1" height="1">
  <feFlood x="4" y="4" width="1" height="1"/>
  <feComposite width="8" height="8"/>
  <feTile result="grid"/>
  <feComposite in="SourceGraphic" in2="grid" operator="in"/>
  <feMorphology operator="dilate" radius="4"/>
</filter>

Step by step:

  1. feFlood paints a single 1ร—1 px dot in the middle of an 8ร—8 cell.
  2. feComposite with width="8" height="8" cuts out that one cell โ€” dot plus empty space.
  3. feTile repeats the cell over the whole button: a grid of dots, one per cell.
  4. feComposite operator="in" keeps the button's pixels only where there is a dot โ€” one sample per cell.
  5. feMorphology dilate grows each sample into a square of the cell's size.

The result: every 8ร—8 block takes the colour of its centre pixel. That's exactly what a low-resolution picture looks like.

2. Switching cell sizes with keyframes

There are four filters โ€” 3, 5, 8 and 12 px โ€” and the keyframes switch between them. filter: url() can't be blended, so every step is a hard switch; the rhythm does the work: the cells grow quickly and gather back a little slower.

.gb-btn:hover {
  animation: gb-pixel 0.75s 1;
}
@keyframes gb-pixel {
  0%, 100% { filter: none; }
  10% { filter: url(#gb-px3); }
  20% { filter: url(#gb-px5); }
  30% { filter: url(#gb-px8); }
  43% { filter: url(#gb-px12); }
  60% { filter: url(#gb-px8); }
  73% { filter: url(#gb-px5); }
  87% { filter: url(#gb-px3); }
}

Bigger than 12 px doesn't work well: the single sample in the middle of a cell starts missing the thin strokes of the letters, and the button simply disappears.

3. Colour noise from feTurbulence

The specks are an SVG file used as a background โ€” noise.svg. Inside it, feTurbulence makes random noise, and two colour matrices push the contrast so hard that every speck is pure red, green, blue or a bright mix of them, and everything darker becomes transparent:

<feTurbulence type="fractalNoise" baseFrequency=".3" numOctaves="2" seed="7"/>
<feColorMatrix values="30 0 0 0 -20  0 30 0 0 -20  0 0 30 0 -20  0 0 0 0 1"/>
<feColorMatrix values="3 0 0 0 0  0 3 0 0 0  0 0 3 0 0  20 20 20 0 -6"/>

The noise sits on the button's ::after, on top of the word. During the glitch it flashes and jumps to a new background-position a few times โ€” one noise image looks like many. Because the pixel filter is on the button, the specks get pixelated together with the word.

4. Plays on hover and on keyboard focus

The animation runs on :hover and on :focus-visible, so keyboard users see the same glitch when they tab to the button. animation-iteration-count comes from --gb-repeat: 1 is right for a real button โ€” one glitch each time you point at it; a bigger number keeps it glitching while the cursor stays.

.gb-btn:hover,
.gb-btn:focus-visible {
  animation: gb-pixel calc(var(--gb-glitch) * 1s) var(--gb-repeat);
}

Make it yours

Variable What it does
--gb-glitch Seconds one glitch takes. 0.4 s is a twitch, 1.5 s is a slow collapse.
--gb-repeat Glitches per hover. Keep 1 on a real page.
--gb-noise Strength of the colour specks; 0 leaves only the pixels.
--gb-size Text size; padding and corners follow it.
--gb-color, --gb-bg Text and border, background.

Spacing: padding is the space between the word and the border (in em, so it grows with the text); margin: 0 is the space around the button on your page โ€” set your own.

The cell sizes live in the SVG (width, height, x, y and radius), not in CSS: for a 6 px cell, put the dot at 3, cut a 6ร—6 cell and dilate by 3.

Gotchas

  • The SVG must be on the page. filter: url(#gb-px8) looks for the filter by id in the same document. Put the <svg> once anywhere in the <body> (it's 0ร—0 and invisible).
  • noise.svg next to the CSS. url(noise.svg) is relative to the CSS file. Inline it as a data URI if you prefer one file.
  • Thin fonts vanish. At 12 px cells, a hairline font loses whole letters. Bold text survives much better.
  • Safari supports these filters, but pixel sizes are in CSS pixels โ€” on a retina screen the cells look half as coarse. That's fine; it still reads as pixelation.

Accessibility

It's a real <button> (or <a>): focusable, works with the keyboard, read as its text. The glitch is decoration and lasts under a second. With prefers-reduced-motion: reduce there is no pixelation and no noise โ€” the button just shows a soft outline on hover.

Variations

  • Glitch on a picture instead of a button: Glitch Image โ€” real RGB channel split and torn strips.
  • The classic torn glitch on text: Glitch Text.
  • A button that glows instead of breaking: Neon Border.

FAQ

How do I make a glitch button hover effect in CSS?

Pick the kind of glitch first. For torn slices, stack copies of the text and shift them with clip-path. For pixelation like here, use SVG filters (feTile + feMorphology) from CSS with filter: url(#id) and switch them in a :hover animation. Neither needs JavaScript.

How do I pixelate an element in CSS?

There's no CSS function for it, but an SVG filter does it: sample one pixel per cell with feFlood + feTile + feComposite, then grow each sample into a square with feMorphology dilate. Apply it with filter: url(#your-filter). It works on text, buttons, images โ€” any element.

Can I make the glitch run all the time, not just on hover?

Yes: move the animation from .gb-btn:hover to .gb-btn and set the iteration count to infinite. Keep it rare on a real page โ€” a button that never stops glitching is tiring.

Why does my pixel glitch make the button disappear?

The cells are too big for the strokes: one sample per cell misses thin lines. Stay at 12 px or smaller, and use a bold font.

Get the code โ€” copy or download
Copy HTML: the markup with your text โ€” paste it where the effect should be. Copy CSS: the styles with your slider settings โ€” paste into your stylesheet. Any text element works: give it the class and a data-text equal to its text.
or
โ†“ Download .zip Both files in one archive โ€” index.html and style.css โ€” with your text and settings. Unzip and open index.html in a browser.
/* Glitch Button โ€” on hover the button falls apart into bigger and
   bigger pixels (3 โ†’ 5 โ†’ 8 โ†’ 12 px) and gathers back, while bright
   R, G, B specks of noise flash over it. Pure CSS + SVG filters.
   Works on <button> and <a>: class="gb-btn" + data-text; the SVG with
   the filters (#gb-px3 โ€ฆ #gb-px12) must be on the page once.
   noise.svg goes next to your CSS file.
   Font: Space Grotesk (Google Fonts), falls back to system-ui.
   Settings: change the variables below. */
.gb-btn {
  --gb-glitch: 0.75;    /* seconds one glitch takes */
  --gb-repeat: 1;       /* glitches per hover (whole number) */
  --gb-noise: 1;        /* colour noise strength, 0 = none */
  --gb-size: 80px;      /* text size; padding and corners follow it */
  --gb-color: #e8ecef;  /* text and border */
  --gb-bg: #0e1012;

  position: relative;
  isolation: isolate;
  margin: 0;                /* margin: space around the button on your page */
  padding: 0.35em 0.8em;    /* padding: space between the word and the border */
  border: 3px solid var(--gb-color);
  border-radius: 0.125em;
  background: var(--gb-bg);
  font: 700 var(--gb-size) "Space Grotesk", system-ui, sans-serif;
  color: var(--gb-color);
  text-decoration: none;
  cursor: pointer;
}

/* Colour noise: bright R, G, B specks on a transparent background.
   They sit on top of the word and get pixelated with it. */
.gb-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: url(noise.svg);
  opacity: 0;
  pointer-events: none;
}

/* Hover or keyboard focus: the glitch plays --gb-repeat times */
.gb-btn:hover,
.gb-btn:focus-visible {
  animation: gb-pixel calc(var(--gb-glitch) * 1s) var(--gb-repeat);
}
.gb-btn:hover::after,
.gb-btn:focus-visible::after {
  animation: gb-noise calc(var(--gb-glitch) * 1s) var(--gb-repeat);
}

/* Cells grow fast and gather back a little slower */
@keyframes gb-pixel {
  0%, 100% { filter: none; }
  10% { filter: url(#gb-px3); }
  20% { filter: url(#gb-px5); }
  30% { filter: url(#gb-px8); }
  43% { filter: url(#gb-px12); }
  60% { filter: url(#gb-px8); }
  73% { filter: url(#gb-px5); }
  87% { filter: url(#gb-px3); }
}
/* The noise jumps to a new spot every few frames and fades out */
@keyframes gb-noise {
  0%, 100% { opacity: 0; background-position: 0 0; }
  13% { opacity: calc(0.9 * var(--gb-noise)); background-position: 37px 11px; }
  30% { opacity: calc(0.5 * var(--gb-noise)); background-position: -23px 41px; }
  47% { opacity: var(--gb-noise); background-position: 61px -17px; }
  67% { opacity: calc(0.4 * var(--gb-noise)); background-position: -9px 29px; }
  87% { opacity: calc(0.15 * var(--gb-noise)); background-position: 47px 5px; }
}

/* Keyboard focus: a quiet ring around the button */
.gb-btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--gb-color) 50%, transparent);
  outline-offset: 0.15em;
}

/* Less motion: no pixels, no noise โ€” the button just reacts with a soft outline. */
@media (prefers-reduced-motion: reduce) {
  .gb-btn:hover,
  .gb-btn:hover::after,
  .gb-btn:focus-visible,
  .gb-btn:focus-visible::after { animation: none; }
  .gb-btn:hover { outline: 2px solid color-mix(in srgb, var(--gb-color) 50%, transparent); }
}