Tailwind CSS Saturate
The saturate
utility in Tailwind CSS sets the saturation of an element's color. It can be used to increase or decrease the saturation of an image or a background color.
Syntax
The saturate
utility follows the below syntax:
/* Default values */
saturate-{amount}
saturate-{amount}-{color}
/* Example */
saturate-50
saturate-75-blue
saturate-{amount}
sets the saturation of the element's color. Theamount
can be a value between 0 to 100.saturate-{amount}-{color}
sets the saturation of the specific color. Theamount
andcolor
are optional values.
Example
<!-- Example 1: Saturate an image -->
<img src="example.jpg" class="saturate-50" alt="Example image">
<!-- Example 2: Saturate a background -->
<div class="bg-gray-500 saturate-75"></div>
<!-- Example 3: Saturate a specific color -->
<div class="text-green-500 saturate-50-green"></div>
Output
The above example codes will generate the following output.
Explanation
- Example 1: The
saturate-50
class set the saturation of the image's color to 50%. - Example 2: The
saturate-75
class sets the saturation of thebg-gray-500
background color to 75%. - Example 3: The
saturate-50-green
class sets the saturation of thetext-green-500
text color to 50%.
Use
The saturate
utility in Tailwind CSS can be used to create visually appealing images and backgrounds with varying levels of saturation.
Important Points
- The
saturate-{amount}
utility can only be used with color-related properties. - The
amount
value can be a number between 0 and 100. - The
saturate
utility can be combined with other color-related utilities to create more complex color styles.
Summary
The saturate
utility in Tailwind CSS sets the saturation of an element's color. It can be used to increase or decrease the saturation of an image or a background color. The saturate
utility can be combined with other color-related utilities to create more complex color styles.