

The core of this technique is supported by all modern browsers. We can’t escape talking about browser support here. What else can you think of? Please let us know what you discover in the comments.

Plus, they can be referenced in a CSS filter and applied to any element in addition to SVG. Apply different SVG filters: There are all kinds of filters, including Gaussian blur and different types of lighting.Add more layers: With CSS blending, you can stack as many any layers as you’d like and blend them down.Try different gradients: Besides linear-gradient, CSS offers four more types of gradients.Use a different SVG: All of the gradients in this article use the same SVG, but you can toy with the parameters that generates the noise to adjust the coarseness as well as the look and feel in the playground.Try the playground and mess around with the different parameters to see how they affect the texture.īeyond that, here are some ways to continue fiddling with this technique: Play around with changing some of the properties of ĬodePen Embed Fallback Taking things further Notice that the SVG is defined separately from the, and the simply references it. This SVG example creates a filter and renders a element that we can use for our grainy gradients. Bence Szabó explains it in much more detail as he demonstrates how it can be used to create patterns. It’s called and we can define attributes, such as whether it is “turbulence” or “noise” and how fine or coarse it is. Within the realm of SVG, we can define filters, and one such filter lets us create Perlin noise. Let’s go into detail on each of these parts. Blend gradients: Finally, we optionally use mix-blend-mode to further filter out colors and blend gradients together.Boost brightness and contrast: Then we turn to CSS filter to increase the brightness and contrast of the noise.Background with gradient and SVG: Next, we drop that filter into CSS as a background image that combines the filter with a CSS gradient.SVG turbulence: This is our noise filter.Here’s what we’re working with under the hood: Layer it underneath a gradient, boost the brightness and contrast, and that’s it - you have gradient that gradually dithers away. The trick is to use an SVG filter to create the noise, then apply that noise as a background. The core technique in this article is built on top of a Stack Overflow answer by Chris Pachl to the question: Can you add noise to a CSS gradient? The quickest way to understand what’s happening is to play with the parameters that make up the layers. Illustration by Jordan Kay on Dribbble Interactive playgroundĬheck it out here.
