Effects
Utilities for controlling an element's mask image.
Class | Styles |
---|---|
mask-[<value>] | mask-image: <value>; |
mask-(image:<custom-property>) | mask-image: var(<custom-property>); |
mask-none | mask-image: none; |
mask-linear-to-t | mask-image: linear-gradient(to top, var(--tw-mask-gradient-stops)); |
mask-linear-to-tr | mask-image: linear-gradient(to top right, var(--tw-mask-gradient-stops)); |
mask-linear-to-r | mask-image: linear-gradient(to right, var(--tw-mask-gradient-stops)); |
mask-linear-to-br | mask-image: linear-gradient(to bottom right, var(--tw-mask-gradient-stops)); |
mask-linear-to-b | mask-image: linear-gradient(to bottom, var(--tw-mask-gradient-stops)); |
mask-linear-to-bl | mask-image: linear-gradient(to bottom left, var(--tw-mask-gradient-stops)); |
mask-linear-to-l | mask-image: linear-gradient(to left, var(--tw-mask-gradient-stops)); |
mask-linear-to-tl | mask-image: linear-gradient(to top left, var(--tw-mask-gradient-stops)); |
mask-linear-<angle> | mask-image: linear-gradient(<angle> in oklab, var(--tw-mask-gradient-stops)); |
-mask-linear-<angle> | mask-image: linear-gradient(-<angle> in oklab, var(--tw-mask-gradient-stops)); |
mask-linear-(<custom-property>) | mask-image: linear-gradient(var(--tw-mask-gradient-stops, var(<custom-property>))); |
mask-linear-[<value>] | mask-image: linear-gradient(var(--tw-mask-gradient-stops, <value>)); |
mask-radial | mask-image: radial-gradient(in oklab, var(--tw-mask-gradient-stops)); |
mask-radial-(<custom-property>) | mask-image: radial-gradient(var(--tw-mask-gradient-stops, var(<custom-property>))); |
mask-radial-[<value>] | mask-image: radial-gradient(var(--tw-mask-gradient-stops, <value>)); |
mask-conic-<angle> | mask-image: conic-gradient(from <angle> in oklab, var(--tw-mask-gradient-stops)); |
-mask-conic-<angle> | mask-image: conic-gradient(from -<angle> in oklab, var(--tw-mask-gradient-stops)); |
mask-conic-(<custom-property>) | mask-image: var(<custom-property>); |
mask-conic-[<value>] | mask-image: <image>; |
mask-from-<color> | --tw-mask-gradient-from: <color>; |
mask-from-<percentage> | --tw-mask-gradient-from-position: <percentage>; |
mask-from-(<custom-property>) | --tw-mask-gradient-from: var(<custom-property>); |
mask-from-[<value>] | --tw-mask-gradient-from: <value>; |
mask-via-<color> | --tw-mask-gradient-via: <color>; |
mask-via-<percentage> | --tw-mask-gradient-via-position: <percentage>; |
mask-via-(<custom-property>) | --tw-mask-gradient-via: var(<custom-property>); |
mask-via-[<value>] | --tw-mask-gradient-via: <value>; |
mask-to-<color> | --tw-mask-gradient-to: <color>; |
mask-to-<percentage> | --tw-mask-gradient-to-position: <percentage>; |
mask-to-(<custom-property>) | --tw-mask-gradient-to: var(<custom-property>); |
mask-to-[<value>] | --tw-mask-gradient-to: <value>; |
Use the mask-[<value>]
syntax to set the mask image of an element:
<div class="bg-[url(/img/mountains.jpg)] mask-[url(/img/scribble.png)] ..."></div>
Use utilities like mask-linear-to-r
and mask-linear-<angle>
with the mask color stop utilities to add a linear gradient mask to an element:
Name | Title | |
---|---|---|
Jane Cooper | Regional Paradigm Technician | jane.cooper@example.com |
Cody Fisher | Product Directives Officer | cody.fisher@example.com |
Leonard Krasner | Senior Designer | leonard.krasner@example.com |
Emily Selman | VP, Hardware Engineering | emily.selman@example.com |
Anna Roberts | Chief Strategy Officer | anna.roberts@example.com |
<div class="relative"> <div class="absolute inset-x-0 bottom-8 z-10 flex items-center justify-center"> <button type="button" class="rounded-full bg-white px-4 py-2 text-sm font-semibold text-gray-900 dark:bg-gray-950 dark:text-white dark:ring-white/20 dark:hover:bg-gray-900 ..." > Show more </button> </div> <div class="max-h-96 mask-linear-to-b mask-from-white mask-from-70% ..."> <table> <!-- ... --> </table> </div></div>
Use the mask-radial
and mask-radial-[<position>]
utilities with the mask color stop utilities to add a radial gradient mask to an element:
Tom Cook
Director of Operations
<div class="flex items-center justify-center"> <div class="relative"> <img class="size-16 rounded-full mask-radial-[circle_at_85%_85%] mask-from-transparent mask-via-transparent mask-via-15% mask-to-white mask-to-15%" src="/img/tom_cook.jpg" /> <div class="absolute right-1 bottom-1 size-3 rounded-full bg-emerald-400 ring inset-ring-1 ring-black/2.5 inset-ring-white/30" ></div> </div> <div class="ml-3 text-sm font-medium"> <p class="text-gray-700 dark:text-gray-300">Tom Cook</p> <p class="text-gray-500">Director of Operations</p> </div></div>
Use the mask-conic
and mask-conic-<angle>
utilities with the mask color stop utilities to add a conic gradient mask to an element:
Storage used: 75%
0.48 GB out of 2 GB remaining
<div class="flex items-center gap-5 rounded-xl bg-white p-4 shadow-lg ring-1 ring-black/5 dark:bg-gray-800"> <div class="grid grid-cols-1 grid-rows-1"> <div class="border-4 border-gray-100 dark:border-gray-700 ..."></div> <div class="border-4 border-amber-500 mask-conic mask-from-white mask-via-white mask-via-75% mask-to-transparent mask-to-75% dark:border-amber-400 ..." ></div> </div> <div class="w-0 flex-1 text-sm text-gray-950 dark:text-white"> <p class="font-medium">Storage used: 75%</p> <p class="mt-1 text-gray-500 dark:text-gray-400"><span class="font-medium">0.48 GB</span> out of 2 GB remaining</p> </div></div>
Use utilities like mask-from-white
, mask-via-transparent
, and mask-to-black
to set the colors of the mask gradient stops:
<div class="bg-[url(/img/mountains.jpg)] mask-linear-to-r mask-from-white mask-via-white/70 mask-to-transparent ..."></div>
Although you can specify any color value for the mask stops, the visibility of a stop depends on the mask-mode
property.
When using mask-mode: luminance
, the luminance value of the color stop determines visibility, so sticking with grayscale colors will produce the most predictable results. With mask-mode: alpha
, the opacity of the color stop determines the visibility of the masked element.
Use utilities like mask-from-10%
, mask-via-30%
, and mask-to-90%
to set more precise positions for the mask gradient color stops:
<div class="bg-[url(/img/mountains.jpg)] mask-linear-to-r mask-from-white mask-from-10% mask-via-white/70 mask-via-30% mask-to-transparent mask-to-90% ..."></div>
Use the mask-none
utility to remove an existing mask image from an element:
<div class="mask-none"></div>
Use utilities like mask-linear-[<value>]
and mask-from-[<value>]
to set the mask image based on a completely custom value:
<div class="mask-linear-[25deg,red_5%,yellow_60%,lime_90%,teal] ..."> <!-- ... --></div>
For CSS variables, you can also use the mask-linear-(<custom-property>)
syntax:
<div class="mask-linear-(--my-mask) ..."> <!-- ... --></div>
This is just a shorthand for mask-linear-[var(<custom-property>)]
that adds the var()
function for you automatically.
Prefix a mask-image
utility with a breakpoint variant like md:
to only apply the utility at medium screen sizes and above:
<div class="mask-from-70% md:mask-from-50% ..."> <!-- ... --></div>
Learn more about using variants in the variants documentation.
Use the --color-*
theme variables to customize the color utilities in your project:
@theme { --color-regal-blue: #243c5a; }
Now utilities like mask-from-regal-blue
,mask-via-regal-blue
, and mask-to-regal-blue
can be used in your markup:
<div class="mask-from-regal-blue"> <!-- ... --></div>
Learn more about customizing your theme in the theme documentation.