@@ -999,21 +999,44 @@ to correctly reproduce the argument scope.
999
999
</xmp>
1000
1000
</div>
1001
1001
1002
- <div class=example>
1003
- Note that [=mixin parameters=] are [=scoped environment variables=]
1004
- rather than [=custom properties=] ,
1005
- which means they exist in a separate namespace
1006
- and don't interfere with [=custom properties=] .
1007
- They can even be used together.
1002
+ Note that [=mixin parameters=] are [=scoped environment variables=]
1003
+ rather than [=custom properties=] ,
1004
+ which means they exist in a separate namespace
1005
+ and don't interfere with [=custom properties=] .
1006
+
1007
+ The two generally act very similarly,
1008
+ except for the slightly different definition syntax
1009
+ (a [=custom property=] versus an ''@env'' rule)
1010
+ and substitution functions
1011
+ (''var()'' versus ''env()'' ),
1012
+ but using [=custom properties=] actually writes those properties
1013
+ into the invoking style rule
1014
+ (potentially interacting with other definitions and uses of that [=custom property=] ,
1015
+ which can be good or bad),
1016
+ while ''@env'' rules in a [=mixin=]
1017
+ aren't visible to anything outside of the [=mixin body=] .
1008
1018
1009
- For example, this code shows how to use a [=custom property=]
1010
- as the fallback for a [=mixin parameter=] :
1019
+ <div class=example>
1020
+ For example, this code shows a [=mixin=]
1021
+ setting [=custom properties=] for other properties to use:
1011
1022
1012
- <pre highlight=css>
1013
- @mixin --var-fallback(--arg: var(--arg)) {
1014
- /* TODO: come up with a believable example */
1023
+ <xmp highlight=css>
1024
+ @mixin --tint-shade(--hue <angle> ) {
1025
+ --light-tint: lch(90% 20% env(--hue));
1026
+ --dark-shade: lch(10% 80% env(--hue));
1015
1027
}
1016
- </pre>
1028
+ .warning {
1029
+ @apply --tint-shade(0deg);
1030
+ background: var(--light-tint);
1031
+ color: var(--dark-shade);
1032
+ padding: .5em;
1033
+ border: thick solid currentcolor;
1034
+ }
1035
+ </xmp>
1036
+
1037
+ If the [=mixin=] had instead declared them as ''@env --light-tint: ...;'' /etc,
1038
+ then those would only be available <em> within</em> the [=mixin body=] ,
1039
+ and the ''.warning'' rule would not be able to use them.
1017
1040
</div>
1018
1041
1019
1042
0 commit comments