# postcss-glitch

> PostCSS plugin for glitch effect

Latest version **7.0.2** (published 2026-09-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install postcss-glitch
pnpm add postcss-glitch
yarn add postcss-glitch
bun add postcss-glitch
```

## Health

**Score 60/100 (C)** — status: active.

Positive: no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 7.0.2 |
| Published | 2026-09-02 |
| First published | 2017-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 99.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 35 |
| Author | Albert Fazullin |
| Maintainers | hex22a |
| Keywords | css, postcss, postcss-plugin, glitch, effect, animation |

## Links

- npm: https://www.npmjs.com/package/postcss-glitch
- Repository: https://github.com/hex22a/postcss-glitch
- Homepage: https://github.com/hex22a/postcss-glitch#readme
- Issues: https://github.com/hex22a/postcss-glitch/issues
- npm.io page: https://npm.io/package/postcss-glitch

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 7.0.2 (latest) — 2026-09-02
- 7.0.1 — 2026-02-02
- 7.0.0 — 2026-02-02
- 6.0.4 — 2026-02-01
- 5.0.1 — 2026-01-27
- 5.0.0 — 2026-01-27
- 4.0.8 — 2026-01-27
- 3.2.38 — 2020-09-30
- 3.2.35 — 2020-08-01
- 3.2.34 — 2020-07-27
- 3.2.16 — 2020-07-27
- 3.2.15 — 2020-07-25
- 3.2.13 — 2020-07-18
- 3.2.12 — 2020-07-17
- 3.2.8 — 2020-02-17
- … 57 more at https://npm.io/package/postcss-glitch/versions

## README

# postcss-glitch

Glitch effect implemented with PostCSS. With this plugin you can add a glitch effect to any text!

[![NPM Version](https://img.shields.io/npm/v/postcss-glitch)](https://badge.fury.io/js/postcss-glitch)
![CI](https://github.com/hex22a/postcss-glitch/actions/workflows/test-plugin.yml/badge.svg)

Check out our [demo page](https://hex22a.github.io/postcss-glitch/) ([source](https://github.com/crftd/postcss-glitch-demos))

## Installation

```bash
npm install postcss-glitch
```

You can use `postcss.config.js` to add plugin to your project just like this:

```javascript
// postcss.config.js

module.exports = {
	plugins: [
		require('postcss-glitch'),
		require('autoprefixer'),
	],
}
```

### Usage

#### TL;DR

```
.foo {
  glitch: <glitch mode> <height in px | pt | % | em | rem > <first color> <second color> <shadow size>;
}
```

#### Guide

##### SVG mode

1. Create an element which you want to apply a glitch effect

```html
<div class="glitch_svg"></div>
```

```postcss
.glitch_svg {
    background-image: url("awesome.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    width: 100px;
    height: 100px;
}
```

2. Add glitch property with mode `svg`

```postcss
.glitch_svg {
    background-image: url("awesome.svg");
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    width: 100px;
    height: 100px;
    glitch: svg 60% #f00 #00f 2px;
}
```

##### Text mode

1. Create an element which you want to apply a glitch effect

```html
<div class="glitch">PostCSS Glitch</div>
```

2. Add a **data-text** attribute to the last created element

```html
<div class="glitch" data-text="PostCSS Glitch">PostCSS Glitch</div>
```

3. Add glitch property with mode `text`

```postcss
.glitch {
	font-weight: 700;
	font-size: 23pt;
	glitch: text 42px #f00 #00f 2px;
}
```

## What actually happens?

> ❗️Note that `.glitch` element becomes a positioning context for its pseudo-elements

```css
.glitch {
	font-weight: 700;
	font-size: 23pt;
	glitch: text 42px #f00 #00f 2px;
}
```

transforms to

```css
@keyframes glitch-animation-before {
	0% {
		clip-path: inset(5px 0 32px 0);
	}
	25% {
		clip-path: inset(14px 0 23px 0);
	}
	50% {
		clip-path: inset(15px 0 22px 0);
	}
	75% {
		clip-path: inset(11px 0 26px 0);
	}
	to {
		clip-path: inset(18px 0 19px 0);
	}
}

@keyframes glitch-animation-after {
	0% {
		clip-path: inset(20px 0 17px 0);
	}
	25% {
		clip-path: inset(37px 0 0 0);
	}
	50% {
		clip-path: inset(16px 0 21px 0);
	}
	75% {
		clip-path: inset(20px 0 17px 0);
	}
	to {
		clip-path: inset(17px 0 20px 0);
	}
}

.glitch {
	position: relative;
	font-weight: 700;
	font-size: 23pt;
}

.glitch:after,
.glitch:before {
	content: attr(data-text);
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	clip-path: inset(42px 0 0 0);
}

.glitch:before {
	text-shadow: -2px 0 #f00;
	animation: glitch-animation-before 3s infinite linear alternate-reverse;
}

.glitch:after {
	text-shadow: 2px 0 #00f;
	animation: glitch-animation-after 2s infinite linear alternate-reverse;
}
```

And yeah, it also works with CSSModules!

### Testing

There are two major groups of tests in this project:

* Tests that are running against source code powered with [jest](https://jestjs.io/)

```bash
# running jest in the watch mode
pnpm --filter postcss-glitch jest

# or alternatively run it without watch mode as it runs on CI server
pnpm --filter postcss-glitch test
```

> If you're having difficulties with running in watch mode see [the installation guide](https://facebook.github.io/watchman/docs/install.html#buildinstall)

---
_Source: https://npm.io/package/postcss-glitch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
