Skip to content

Instantly share code, notes, and snippets.

@karol-majewski
Created April 14, 2026 23:23
Show Gist options
  • Select an option

  • Save karol-majewski/b77ced607c7c68ec7deaff02ffffae42 to your computer and use it in GitHub Desktop.

Select an option

Save karol-majewski/b77ced607c7c68ec7deaff02ffffae42 to your computer and use it in GitHub Desktop.
Parametric noisy backgrounds in Tailwind CSS v4
/* Fine noise */
@utility noise-* {
position: relative;
--noise-opacity: calc(--value(integer) * 1%);
&::before {
content: "";
position: absolute;
inset: 0;
opacity: var(--noise-opacity);
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.3'/%3E%3C/svg%3E");
pointer-events: none;
}
}
@karol-majewski
Copy link
Copy Markdown
Author

karol-majewski commented Apr 14, 2026

Usage:

Applies noise with 5% opacity:

<div className="noise-5" /> 

Applies noise with 90% opacity:

<div className="noise-90" /> 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment