17Manipulating @content

Mixins can have full declaration blocks passed into them when they are included. When declaring the mixin, you can include the content that’s passed in by using the @content directive.

This is useful for some complex mixins and libraries. It isn’t used that often, but you can build some clever and useful mixins with it.

In the example, you want to style the page slightly differently if the summer sales attribute is on the body. You don’t want to have to type out that long, ungainly selector every time you want to make a small adjustment to the styles. This is a perfect situation for passing in a content block! You can see in the mixin declaration that there’s also an & to indicate the body rule should be at the top ...

Get Pragmatic Guide to Sass 3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.