0
0
SASSmarkup~5 mins

Content blocks with @content in SASS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the @content directive do in Sass?

The @content directive allows you to pass a block of styles into a mixin, letting you insert custom CSS where @content is placed.

Click to reveal answer
beginner
How do you define a mixin that uses @content in Sass?

You define a mixin with @mixin and inside it, use @content where you want the passed styles to appear.

@mixin example() {
  border: 1px solid black;
  @content;
}
Click to reveal answer
beginner
How do you include a mixin with a content block in Sass?

You use @include followed by curly braces {} containing the styles you want to pass as the content block.

@include example() {
  background: yellow;
}
Click to reveal answer
intermediate
Why use @content instead of just passing arguments to a mixin?

@content lets you pass a whole block of CSS rules, not just values. This gives more flexibility to add complex or multiple styles inside the mixin.

Click to reveal answer
intermediate
Can you use @content multiple times inside one mixin?

No, @content can only be used once inside a mixin. It marks the single place where the passed block of styles will be inserted.

Click to reveal answer
What keyword do you use inside a Sass mixin to insert a block of styles passed from @include?
A@content
B@block
C@insert
D@pass
How do you pass styles to a mixin that uses @content?
AUsing parentheses with arguments
BUsing curly braces after <code>@include</code>
CUsing a separate CSS file
DUsing <code>@extend</code>
Can @content be used more than once inside the same mixin?
AOnly if you use <code>@repeat</code>
BYes, multiple times
CNo, only once
DOnly inside nested mixins
What is a benefit of using @content in Sass mixins?
AIt allows passing multiple CSS rules as a block
BIt compiles CSS faster
CIt replaces variables
DIt automatically prefixes CSS
Which of these is the correct way to define a mixin with @content?
A@mixin example() { @block; }
B@mixin example() { content; }
C@mixin example() { @include content; }
D@mixin example() { @content; }
Explain how @content works in Sass mixins and why it is useful.
Think about how you can insert custom CSS inside a reusable style block.
You got /4 concepts.
    Describe the steps to create and use a Sass mixin that accepts a content block.
    Imagine you want to reuse a style but add different inner styles each time.
    You got /4 concepts.