Opacity
Standard opacity utility classes with module mixins for responsive modifiers.
Examples (anchor)
Fixed utilities:
.opacity-100
.opacity-75
.opacity-50
.opacity-25
A variable utility (.opacity-v) to customize opacity in real-time:
--op:0.85
--op:0.66
--op:0.33
--op:0.15
<div class="grid-columns g-4 gap-2 mb-3">
<div class="bg-primary py-4 opacity-v" style="--op:0.85;"></div>
<div class="bg-primary py-4 opacity-v" style="--op:0.66;"></div>
<div class="bg-primary py-4 opacity-v" style="--op:0.33;"></div>
<div class="bg-primary py-4 opacity-v" style="--op:0.15;"></div>
</div>Using the module (anchor)
Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.
@use "stylemods/scss" as *;
@include opacity-css;Responsive modifier mixins can be included in custom breakpoints:
@use "stylemods/scss" as *;
@include opacity-css;
@media (max-width: 480px) {
@include opacity-sm-css;
}See the using modules page for more information.
Using the framework (anchor)
Using the recommended custom setup enable the styles in an overrides document:
@use "stylemods/scss/configuration" as *;
$enable-opacity: true;
// Breakpoints
$enable-opacity-lg: true;
$enable-opacity-md: true;
$enable-opacity-sm: true;Include the overrides and the framework styles with your custom document for compiling the framework:
@use "overrides";
@use "stylemods/scss/stylemods";See using the framework for more information.
Source code (anchor)
The Opacity source file is included with the utilities module files, you can view the source code from the latest release (v1.5.0) via the Github link below.
- Source document
- stylemods/scss/utilities/opacity.scss
- View on Github
- https://github.com/pmbrown/StyleMods/blob/main/scss/utilities/opacity.scss
Shared documentation about how to customize the default property values for the styles using the Sass and CSS variables is provided on the customizing page.