Skip to content

Grayscale

Utilities for applying grayscale to an element.

Quick reference

ClassProperty
grayscalefilter: grayscale(1);
grayscale-0filter: grayscale(0);

Usage

Use the grayscale-{amount} class for setup ratio aspect.

html

<div class="grayscale-0">
    <!-- ... -->
</div>

Applying conditionally

Breakpoints and media queries

You can also control the responsive breakpoint with variant class modifiers. For example lg:grayscale will be only apply on large screens size and above.

html

<div class="grayscale-0 lg:grayscale">
    <!-- ... -->
</div>

Customization

Extend your theme

By default, the configuration provides a handful of general purpose grayscale utilities. You can easily extend the default scales using the Sass configuration.

scss
@use "lasco" with (
    $extend: (
        "grayscale": (
            "50": "0.5"
        )
    )
);

Note: the amount can be a number (0 to 1) or a percentage value. ( Source MDN)

Released under the MIT License.