shadcn.io is not affiliated with official shadcn/ui
Glitch Shader draws a screen carrying a corrupted signal. Three channels of soft value noise, sampled at slightly different, wobbling offsets, make blotchy green, yellow, pink and teal patches, under a grid of grey blocks and scrolling scanlines. On top, one block in ten is data-moshed out of place, a few columns and rows are corrupted to purple, a torn row slips sideways now and then, and static and green sparkle crawl over everything. A WGSL fragment shader on WebGPU computes every pixel each frame, for about half a millisecond of GPU time.
Every glitch runs on its own clock: each block, column and row changes at most once a second, at its own moment, so the screen churns without ever strobing. Use it behind a 404 or "signal lost" page, a game's menu or a cyberpunk launch. For a calm picture torn by short bursts, in plain CSS, use the Glitch background; for green code rain, Matrix Shader; for flipping binary digits, Binary Shader. It runs only while it's on screen, holds a still frame with reduced motion, and shows a CSS picture of the same signal in browsers without WebGPU.
Installation
Usage
import { GlitchShader } from "@/components/ui/glitch-shader";<GlitchShader className="flex min-h-[32rem] items-center justify-center">
<div className="rounded-xl bg-black/70 px-8 py-6">
<h1 className="font-mono text-5xl font-semibold text-white">Signal lost</h1>
</div>
</GlitchShader>Glitch Shader is a container: your content sits on top of the signal, in normal flow. It fills its own box, so give it a height or content. For a backdrop behind the whole page, render it empty with className="fixed inset-0 -z-10". The colors are mid-tones that reach near-white in the yellow patches and the sparkle, so white text reads on only about 60% of the screen: put copy on a panel, like the bg-black/70 one above, which keeps white text above 8.5:1 everywhere (bg-black/60, above 5.7:1).
Demos
Cyan, fine scanlines
accentColor="#22d3ee" tints the corrupted stripes and rows cyan instead of purple, and scanlines={2} makes the lines twice as fine, for a sharper, more electronic screen.
In a card
intensity={0.5} halves the color split, the static and the sparkle, and distortion={0.4} keeps the moshed blocks close to home, so a card stays readable. The scanlines and the static are sized in CSS pixels, so they look the same at any screen ratio.
Performance
About 0.5 ms of GPU time a frame at 1280×720 on an M2 Max laptop; slower GPUs take several times longer. It keeps the default quality: half resolution would blur the scanlines and the static, which are the point. distortion and intensity don't change the cost. The animation stops when the shader scrolls out of view, and the browser pauses it in a hidden tab. Every shader on a page shares one GPU device and one frame loop, and vgpu (about 50 KB gzipped) loads only when the first one mounts.
Browser support
The shader needs WebGPU: Chrome and Edge, Safari 26 and later, and Firefox on Windows and macOS. Elsewhere, and until the first frame, the box shows a CSS picture of the signal, color patches under scanlines with two purple stripes, so the layout never jumps. data-state on the root reads unsupported there, if you want to style around it. See Shader Canvas.
Accessibility
The signal is decoration: it's hidden from assistive tech and lets every click through to your content. With reduced motion it draws one still frame and stops. It's built not to flash: each block, column and row changes at most once a second, on its own clock, so large areas never change together; a tear shows at most twice a second, one at a time; and the static and sparkle are single pixels, too small to count. Measured over 10 seconds with WCAG's area test (a quarter of a 10° field), it never flashes; even 32-pixel patches flash at most twice a second. speed is capped at 1.5, which keeps that under three. White text needs a dark panel, as in Usage.
FAQ
Is it safe for people sensitive to flashing?
It's designed to be. Every glitch layer runs on staggered clocks, so no large area changes at once, and no spot changes more than a couple of times a second; it passes WCAG's three-flashes test with room to spare, and speed is capped at 1.5 so it can't be pushed past it. With reduced motion it draws one still frame. shadcn.io's version re-randomized its block layer every frame and flipped its stripes ten times a second; this one doesn't.
What makes the color split?
The red, green and blue channels each read the same noise pattern at a slightly different offset, and the offsets wobble on their own sine waves, like a misaligned video signal. intensity sets how far apart they drift, along with the static and the sparkle.
What is data-moshing here?
The screen is cut into a 10 by 10 grid of blocks, and one block in ten is pushed out of place, up to a tenth of the screen at distortion={2}, carrying its colors and scanlines with it. Each block re-rolls once a second on its own clock, so the misplaced ones come and go one by one.
How do I tone it down behind text?
Lower intensity and distortion, as in the card demo, or slow it with speed={0.5}. For copy, add a dark panel behind it, such as bg-black/70, rather than dimming the whole shader.
API Reference
GlitchShader
data-slot="glitch-shader"
accentColor?string
The tint of the corrupted stripes and rows. Any CSS colour. @default "#ff33cc".
- Default
"#ff33cc"
distortion?number
How far the data-moshed blocks are pushed out of place, from 0 (not at all) to 2. @default 1.
- Default
1
fallback?string
What shows until the first frame and in browsers without WebGPU: a CSS
background value (gradients, sizes, a colour) that looks like the
shader. It can use the colour props' --shader-<field> variables.
intensity?number
The colour split, static and pixel sparkle, from 0 (clean) to 2. @default 1.
- Default
1
interactive?boolean
Whether u.pointer follows the pointer. @default false.
paused?boolean
Holds the current frame. @default false.
quality?number
Render scale, from 0.25 to 1, of the screen's pixels (capped at 2×). @default 1.
scanlines?number
How fine the scanlines are, from 0.5 (wide) to 3 (fine). @default 1.
- Default
1
speed?number
Animation speed, capped at 1.5 so the glitches stay under three flashes a second. @default 1.
- Default
1
time?number
A fixed moment, in seconds: draws it and doesn't animate.
render?ReactElement | ((props: object, state: object) => ReactElement)
Replace the host element or compose it with another component.
- Type
ReactElement | ((props: object, state: object) => ReactElement)
className?string
Forwarded to the part.
Related


Matrix Shader
Digital & retroGreen code rain, free
- Pro


Binary Shader
Digital & retroFlipping binary digits
- Pro


CRT Phosphor Shader
Digital & retroA clean old screen, no tearing
- Pro


Pixel Sort Shader
Digital & retroGlitch art that stays calm


Hologram Shader
Light & glassA clean projection, free
- Pro


Monster Tunnel Shader
Tunnels & 3DMenacing energy for a game