When Spotify launched their colorful new brand identity, featuring hip duo-toned imagery, it went hand-in-hand with a new Colorizer tool that allows artists to apply a variety of filters to images. This solved a problem in which Spotify needed a way to present the thousands of images uploaded, all with a different look and feel, in a way that keeps them uniform with the brand. This is one of the most common problems facing web design, especially when the app or website content is outside the control of a full-time art director. This tutorial will show you how to use pure CSS to achieve a wide variety of Spotify colorizer effects that can be applied to any image.
Mix Blend Mode
The key to creating duo-tone effects in Photoshop is to colorize the whites and blacks of a grayscale image by sandwiching it between two color layers. The first layer establishes the foundation color, the photo layer is set to the Multiply blend mode, and the top layer set to the Lighten blend mode to colorize the blacks in the image or vice versa. This same basic technique can be applied using CSS thanks to the
mix-blend-mode property can be used on just about any element, including pseudo-elements, to blend it with whatever is behind it. This should not be confused with its companion property,
background-blend-mode, which is specifically for blending multiple images in a
mix-blend-mode supports the following familiar Photoshop layer blend-mode values:
The majority of the Spotify-style effects are achieved using a combination of
lighten, but I’ve included a few variations so you can see how other combos can work together.
See the Pen Spotify Colorizer Effects Using CSS Blend Modes by Vail (@vailjoy) on CodePen.0
Full Screen Demo
Let’s take a look at the core style set:
For these styles to work, your images need to be wrapped by something, whether it be a
<div class="column green"><img src="path/to/image"/></div>
This wrapper will serve as the first layer, with the top layer being added using a pseudo-element.
Each CSS class has three primary parts – the background color, the image filter, and the top color layer created using
1 – Background
For each style, a background color is set on the image wrapper:
Bright colors on images with large areas of white or black will give you the best results.
2 – Image
For duo-tones to look best, a high-contrast black and white image must be used. Since the problem we are solving has to do with unpredictable image types of all colors, you can use CSS
filter to turn the image
grayscale, then set a
contrast level that works best.
We then set
multiply, just like we would in Photoshop.
filter: grayscale(100%) contrast(1);
For situations where you don’t know what the images will look like, a contrast level of 1.2 is a good start. Going below 1 (such as .8) will fade the image more, and can cause the effect to be lost on photos that already have a faded filter or low contrast to begin with. A high level, such as 2, can cause too much detail to be lost but can give you an interesting "screen-printed" look.
3 – Color Overlay
The color overlay can be a
span or a
div, but it is much easier to simply create a pseudo-element using
::after on the image wrapper element.
First we need to establish the element and position it over the image. Our image wrapper has a class of column we’ll use to do this so our color effect classes can focus on just their effects.
transition: all ease-in-out .5s;
Now we can add the background color and mix mode to this element each of our effect style sets:
In this particular style, the
lighten mix mode applies the blue color to the dark areas of the image. You can also swap
lighten around to get different results – the modes you select depend the most on the color combination you are using and the look you are after.
Going Beyond Multiply and Lighten
multiply is making things too dark, try
darken instead. Want a simple color overlay? Try
color on the
You can also use gradients on your overlay for a little extra dimension as shown in the demo. Like the other effects, there are countless ways to combine the mix modes. A dark colored background color works best with
lighten on the image and and
hard-light on the overlay where your gradient background is declared. For light background colors, you can stick with the basic darken/lighten or multiply/lighten combo.
Here is what our purple and green gradient style set looks like all together:
-webkit-filter: grayscale(100%) contrast(1.2);
filter: grayscale(100%) contrast(1.2);
background: linear-gradient(to top left, #75d775, #321a5b);
Spotify’s successful campaign was created by the Collins design firm with the goal to reconnect us with the emotional impact of the music we listen to. The visual styling combines the retro feel of familiar filters with today’s strong attraction to minimal shapes and vibrant color. The result is simple, fresh and easily identifiable. Using CSS blend modes is a great way to unify the look of content across a website, and these Spotify Colorizer style effects offer a timeless pop of color for your bespoke designs, too.
CSS mix-blend-modes are supported in webkit browsers, but not in IE (yet). It is a candidate in CSS level 4 which expects wide adoption this year. If you would like to ensure these effects only load on browsers that can render them, you can use the @supports rule to wrap the effect styles.
If you’ve come up with some cool combinations not shown in our demo, share your code or links in the comments!