Skip to content

Grayscale

Applies a grayscale filter to an element.

Utility Properties
Error: 429

This example showcases various grayscale() filter utilities:

  • The f-g-0 grayscale utility sets the filter property to grayscale(0%), meaning no grayscale is applied, and the colors remain unchanged.
  • The f-g-50 grayscale utility sets the filter property to grayscale(50%), applying a moderate grayscale effect, resulting in a mix of color and gray.
  • Finally, f-g-100 grayscale utility sets the filter property to grayscale(100%), completely removing all color and rendering the element in shades of gray.
<div class="d-g g-16 gtc-1 sm:gtc-3">
<div class="d-32 p-r rad-1">
<img class="d-full f-g-0 of-c rad-1" src="https://picsum.photos/300?image=875" />
</div>
<div class="d-32 p-r rad-1">
<img class="d-full f-g-50 of-c rad-1" src="https://picsum.photos/300?image=875" />
</div>
<div class="d-32 p-r rad-1">
<img class="d-full f-g-100 of-c rad-1" src="https://picsum.photos/300?image=875" />
</div>
</div>

Conditional styles

Learn how to override existing utilities based on the userโ€™s screen size or other factors, such as hover states.

Media modifier

You can combine responsive breakpoints like sm:-*,md:-*, lg:-*, and xxl:-* allows targeting specific utilities in different viewports.

<div class="f-g-0 md:f-g-100 ..."></div>

Hover modifier

Alternatively, you can apply :hover by using h:-* utility to override elements and change their values when hovering over them.

<div class="f-g-0 h:f-g-100 ..."></div>