Filters
Utilities for applying contrast filters to an element.
Class | Styles |
---|---|
contrast-<number> | filter: contrast(<number>%); |
contrast-(<custom-property>) | filter: contrast(var(<custom-property>)); |
contrast-[<value>] | filter: contrast(<value>); |
Use utilities like contrast-50
and contrast-100
to control an element's contrast:
Use the contrast-[<value>]
syntax to set the contrast based on a completely custom value:
<img class="contrast-[.25] ..." src="/img/mountains.jpg" />
For CSS variables, you can also use the contrast-(<custom-property>)
syntax:
<img class="contrast-(--my-contrast) ..." src="/img/mountains.jpg" />
This is just a shorthand for contrast-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a filter: contrast()
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<img class="contrast-125 md:contrast-150 ..." src="/img/mountains.jpg" />
Learn more about using variants in the variants documentation.