Global CSS Options with Custom Properties
In a preprocessor such as Sass, a logical "do this or don't" flag is easy to build:
$option: false;
@mixin doThing {
@if $option {
do-thing: yep;
}
}
.el {
@include doThing;
}
The same trick works in vanilla CSS with custom properties, as Mark Otto demonstrates. The approach only differs slightly.
html {
--component-shadow: 0 .5rem 1rem rgba(0,0,0,.1);
}
.component {
box-shadow: var(--component-shadow);
}
<!-- override the global anywhere more specific! like
<div class="component remove-shadow">
or
<body class="remove-shadow"> -->
.remove-shadow {
--component-shadow: none;
}



