From the course: Sass Essential Training

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Each

Each

“

- [Instructor] Now that we understand lists and how to access them, let's talk about some of the ways that you can get to the element, starting with the @each rule. The each statement allows you to emit a number of styles based on a list or a map, which we'll get into a little bit later. Use an at rule with a variable to use for each statement as you navigate through an expression. Now, the expression is usually a list or something that computes to a list, like some of the methods that we saw in the previous video. You can also use destructuring, so that you can create a series of variables from a complex list. Here's a good example, based on some of the things that we've been doing with buttons. We're creating a mix in here to go through a button and create it based on a name, a background, and optionally, a color. And so what we're doing here is creating a list, and this list has two elements. Each element is…

Contents