# Source: https://github.com/tailwindlabs/tailwindcss.com/blob/main/src/docs/mask-composite.mdx

import { ApiTable } from "@/components/api-table.tsx";
import { Example } from "@/components/example.tsx";
import { Figure } from "@/components/figure.tsx";
import { ResponsiveDesign } from "@/components/content.tsx";

export const title = "mask-composite";
export const description = "Utilities for controlling how multiple masks are combined together.";

<ApiTable
  rows={[
    ["mask-add", "mask-composite: add;"],
    ["mask-subtract", "mask-composite: subtract;"],
    ["mask-intersect", "mask-composite: intersect;"],
    ["mask-exclude", "mask-composite: exclude;"],
  ]}
/>

## Examples

### Basic example

Use utilities like `mask-add` and `mask-intersect` to control how an element's masks are combined together:

<Figure>

<Example>
  {
    <div className="grid grid-cols-2 items-center justify-center justify-items-center gap-y-8 py-4 text-center font-mono text-xs font-medium text-gray-500 max-sm:grid-cols-1 dark:text-gray-400">
      <div className="relative grid justify-center">
        <div className="absolute right-[calc(5%-2px)] -bottom-[2px] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <div className="absolute -bottom-[2px] left-[calc(5%-2px)] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <p className="mb-3">mask-add</p>
        <div className="h-24 w-48 bg-[url(https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&h=1000&q=80)] mask-[radial-gradient(ellipse_25%_50%_at_30%_50%,_white_100%,transparent_100%),_radial-gradient(ellipse_25%_50%_at_70%_50%,_white_100%,transparent_100%)] bg-cover bg-center mask-add"></div>
      </div>
      <div className="relative grid justify-center">
        <div className="absolute right-[calc(5%-2px)] -bottom-[2px] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <div className="absolute -bottom-[2px] left-[calc(5%-2px)] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <p className="mb-3 text-center">mask-subtract</p>
        <div className="h-24 w-48 bg-[url(https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&h=1000&q=80)] mask-[radial-gradient(ellipse_25%_50%_at_30%_50%,_white_100%,transparent_100%),_radial-gradient(ellipse_25%_50%_at_70%_50%,_white_100%,transparent_100%)] bg-cover bg-center mask-subtract"></div>
      </div>
      <div className="relative grid justify-center">
        <div className="absolute right-[calc(5%-2px)] -bottom-[2px] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <div className="absolute -bottom-[2px] left-[calc(5%-2px)] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <p className="mb-3 text-center">mask-intersect</p>
        <div className="h-24 w-48 bg-[url(https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&h=1000&q=80)] mask-[radial-gradient(ellipse_25%_50%_at_30%_50%,_white_100%,transparent_100%),_radial-gradient(ellipse_25%_50%_at_70%_50%,_white_100%,transparent_100%)] bg-cover bg-center mask-intersect"></div>
      </div>
      <div className="relative grid justify-center">
        <div className="absolute right-[calc(5%-2px)] -bottom-[2px] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <div className="absolute -bottom-[2px] left-[calc(5%-2px)] box-content size-24 rounded-full border-2 border-dashed border-black/10 dark:border-white/20" />
        <p className="mb-3 text-center">mask-exclude</p>
        <div className="h-24 w-48 bg-[url(https://images.unsplash.com/photo-1554629947-334ff61d85dc?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1000&h=1000&q=80)] mask-[radial-gradient(ellipse_25%_50%_at_30%_50%,_white_100%,transparent_100%),_radial-gradient(ellipse_25%_50%_at_70%_50%,_white_100%,transparent_100%)] bg-cover bg-center mask-exclude"></div>
      </div>
    </div>
  }
</Example>

{/* prettier-ignore */}
```html
<!-- [!code classes:mask-add,mask-subtract,mask-intersect,mask-exclude] -->
<div class="mask-add mask-[url(/img/circle.png),url(/img/circle.png)] mask-[position:30%_50%,70%_50%] bg-[url(/img/mountains.jpg)]"></div>
<div class="mask-subtract mask-[url(/img/circle.png),url(/img/circle.png)] mask-[position:30%_50%,70%_50%] bg-[url(/img/mountains.jpg)]"></div>
<div class="mask-intersect mask-[url(/img/circle.png),url(/img/circle.png)] mask-[position:30%_50%,70%_50%] bg-[url(/img/mountains.jpg)]"></div>
<div class="mask-exclude mask-[url(/img/circle.png),url(/img/circle.png)] mask-[position:30%_50%,70%_50%] bg-[url(/img/mountains.jpg)]"></div>
```

</Figure>

### Responsive design

<ResponsiveDesign property="mask-composite" defaultClass="mask-add" featuredClass="mask-subtract" />