SASS variables compile at runtime, CSS custom properties compile when they're used.
This is a key insight that is overlooked by many comparisons - and as such one that should be leveraged to the fullest extent.
Following the advice of Don’t do it at runtime. Do it at design time. Sass variables should really be the default. The move to CSS custom properties becomes only really necessary when the value can vary during runtime - as it will with a dynamic theme.
Now the local override is nice if somewhat orphaned as it assumes that the flex utility is being used. And given that width can change at runtime using a CSS custom property seems appropriate.
This is a key insight that is overlooked by many comparisons - and as such one that should be leveraged to the fullest extent.
Following the advice of Don’t do it at runtime. Do it at design time. Sass variables should really be the default. The move to CSS custom properties becomes only really necessary when the value can vary during runtime - as it will with a dynamic theme.
Another example I recently ran across:
where
and later
Now the local override is nice if somewhat orphaned as it assumes that the
flex
utility is being used. And given that width can change at runtime using a CSS custom property seems appropriate.However consider the following:
flex
is captured as amixin
.flex
is tightly coupled toprimary-navigation
anyway and now that's clear from the rule.