⊗mkLsBsMxNP 20 of 42 menu

Named Mixin Parameters in SASS

Mixins can have named parameters. Let's look at this with the following example:

@mixin active($color) { border: { color: $color; style: solid; } } p { @include active($color: orange); } div { @include active($color: green); }

Compilation result:

p { border-color: orange; border-style: solid; } div { border-color: green; border-style: solid; }

In addition, you can pass default parameter values ​​to mixins:

@mixin active($color, $width: 2px) { border: { color: $color; width: $width; style: dotted; } } p { @include active(yellow); } div { @include active(yellow, 4px); }

After compilation we will see:

p { border-color: yellow; border-width: 2px; border-style: dotted; } div { border-color: yellow; border-width: 4px; border-style: dotted; }

Tell me what the result of compiling the following code will be:

@mixin super-button($color, $background-color, $border-radius) { color: $color; background-color: $background-color; border-radius: $border-radius; } .active-button { @include super-button($color: white, $background-color: red, $border-radius: 2px); }

Tell me what the result of compiling the following code will be:

@mixin super-button($color, $background-color, $border-radius: 5px) { color: $color; background-color: $background-color; border-radius: $border-radius; } .active-button { @include super-button($color: white, $background-color: red); }

Tell me what the result of compiling the following code will be:

@mixin super-button($color, $background-color: orange, $border-radius: 5px) { color: $color; background-color: $background-color; border-radius: $border-radius; } .active-button { @include super-button($color: white, $border-radius:3px); }
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline