Loading
Animated Background Stripes Effect 12 exercises
Problem

Create Opacity Modifier Utilities

We're going to create opacity modifier utilities that work with all of Tailwind's opacity values.

Instead of manually adding classes for each value like we did for the white and reverse, we'll use the more powerful match utilities function.

Loading exercise

Transcript

0:00 Now things are getting really interesting. We want to create opacity modifier utilities, but they should work with all of Tailwind's opacity values. You can see down here I have classes for opacity 75, 50, 25, for the black stripes and the white stripes. These classes currently don't exist. There's also more values to support.

0:19 Instead of doing it manually like we've done for the white and reverse, we'll need to do something a bit more dynamic. Instead of using addUtilities, this time we're going to use another function called matchUtilities. This one is way more powerful. It's kind of mind-bending at first, but once you get the hang of it, it's super-cool.