0
0
SASSmarkup~8 mins

Mixin definition with @mixin in SASS - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Mixin definition with @mixin
[Read @mixin name] -> [Store mixin code block] -> [Wait for @include] -> [Insert mixin styles] -> [Compile CSS]
Sass preprocessor reads the @mixin definition and stores it. When @include is encountered during compilation, it inserts the mixin styles into the output CSS.
Render Steps - 3 Steps
Code Added:@mixin rounded-corners { border-radius: 10px; box-shadow: 2px 2px 5px gray; }
Before
No CSS output yet
After
Mixin stored in Sass compiler (no CSS generated yet)
Sass compiler defines and stores the mixin but generates no CSS until rules are processed.
🔧 Browser Action:
Code Sample
A div with blue text and rounded corners with shadow from the mixin, compiled from Sass to CSS.
SASS
<div>This is a div with rounded corners and shadow.</div>
SASS
div {
  color: blue;
  border-radius: 10px;
  box-shadow: 2px 2px 5px gray;
}
Render Quiz - 3 Questions
Test your understanding
What happens when Sass compiler sees @mixin rounded-corners { ... }?
AImmediately applies styles to all elements
BIgnores it if no @include
CStores it for later @include usage
DCompiles to CSS immediately
Common Confusions - 3 Topics
Does the browser execute @mixin and @include?
No, Sass preprocessor compiles them to plain CSS before the browser sees it. Browser only renders final CSS.
💡 Sass → Compiler → CSS → Browser. Mixins never reach the browser.
Why no visual change until @include?
@mixin only defines; @include expands it into the stylesheet during Sass compilation.
💡 @mixin = blueprint; @include = build the house.
Can mixins have parameters?
Yes, e.g., @mixin rounded($radius) { border-radius: $radius; }. This example is parameterless.
💡 Parameters make mixins flexible like functions.
Property Reference
Directive/PropertyValue/ExampleEffectCommon Use
@mixinrounded-corners { ... }Defines reusable style blockCode reuse in Sass
@includerounded-cornersInserts mixin stylesApply reusable styles
border-radius10pxRounds element cornersModern UI design
box-shadow2px 2px 5px grayAdds drop shadowVisual depth
colorblueSets text colorTypography
Concept Snapshot
@mixin defines reusable Sass style blocks. @include inserts/expands them during compilation. Result: DRY CSS without repetition. Compiler-only: browser sees plain CSS. Ex: Reuse rounded-corners + shadow.