-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new mask-image
utilities for Tailwind CSS v4.1
#17134
Merged
Merged
+9,831
−3
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
631b8ff
to
5810e13
Compare
c57d5fd
to
fdb228c
Compare
mask-*
utilities for mask-image
, mask-composite
, etc…mask-image
utilities for Tailwind CSS v4.1
f3d4333
to
7da2742
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one!
I did notice that we have a utility duplicated (mask-none
), and there are a few cases where we don't have explicit tests for.
RobinMalfait
approved these changes
Mar 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💪
RobinMalfait
approved these changes
Mar 28, 2025
This means that the default makes sense for `mask-composite: intersect` whether you’re using an alpha or luminance mask
ea41b04
to
04352a3
Compare
28 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new set of composable
mask-image
utilities, designed to make it easy to create common masking effects while still offering complete control for very custom masks using arbitrary values.For a quick demo with practical examples, take a look at this prototype that was built in Tailwind Play:
Live prototype
Note: that this prototype contains some implementation differences. There are extra, unnecessary declarations to make the utilities sort correctly which are not needed in core. Also the
@property
declarations in the prototype are just properties on*
instead of using@property
which the actual implementation uses.API reference
Linear masks
Masking single edges
mask-t-from-*
(e.g.mask-t-from-80%
)mask-t-to-*
(e.g.mask-t-to-90%
)mask-r-from-*
(e.g.mask-r-from-80%
)mask-r-to-*
(e.g.mask-r-to-90%
)mask-b-from-*
(e.g.mask-b-from-80%
)mask-b-to-*
(e.g.mask-b-to-90%
)mask-l-from-*
(e.g.mask-l-from-80%
)mask-l-to-*
(e.g.mask-l-to-90%
)Notes:
from
andto
are optional as long as the other one is specifiedSymmetrical masks
mask-x-from-*
(e.g.mask-x-from-80%
)mask-x-to-*
(e.g.mask-x-to-90%
)mask-y-from-*
(e.g.mask-y-from-80%
)mask-y-to-*
(e.g.mask-y-to-90%
)Notes:
mask-l-from
andmask-r-from
at the same time — each of these utilities contributes to two separate gradients, they aren't combined into a single linear gradientCustom linear masks
mask-linear-*
(e.g.mask-linear-45
)mask-linear-from-*
(e.g.mask-linear-from-50%
)mask-linear-to-*
(e.g.mask-linear-to-75%
)Notes:
mask-linear-*
can be both a bare angle that's used with themask-linear-from-*
andmask-linear-to-*
utilities, or it can be a complete arbitrary linear gradient likemask-linear-[black_10%,transparent_85%]
from
andto
both have defaults so they are both optionalRadial masks
Radial mask size
mask-radial-*
(e.g.mask-radial-[50%_75%]
)mask-radial-closest-side
closest-side
mask-radial-closest-corner
closest-corner
mask-radial-farthest-side
fartheset-side
mask-radial-farthest-corner
farthest-corner
mask-radial-closest-corner
closest-corner
Notes:
mask-radial-*
can be just a size when combined with utilities likemask-radial-from-*
, or it can be used to provide a complete arbitrary radial mask likemask-radial-[circle_at_top,black_25%,transparent_80%]
Radial mask shape
mask-circle
circle
mask-ellipse
ellipse
Notes:
mask-ellipse
is the default, so it's only really useful to "undo"mask-circle
Radial mask position
mask-radial-at-*
(e.g.mask-radial-at-[25%_100px]
)mask-radial-at-top
top
mask-radial-at-top-left
top left
mask-radial-at-top-right
top right
mask-radial-at-bottom
bottom
mask-radial-at-bottom-left
bottom left
mask-radial-at-bottom-right
bottom right
mask-radial-at-left
left
mask-radial-at-right
right
Notes:
Radial mask stops
mask-radial-from-*
(e.g.mask-radial-from-80%
)mask-radial-to-*
(e.g.mask-radial-to-90%
)Notes:
Conic masks
mask-conic-*
(e.g.mask-conic-45
)mask-conic-from-*
(e.g.mask-conic-from-50%
)mask-conic-to-*
(e.g.mask-conic-to-75%
)Notes:
mask-conic-*
can be just an angle when combined with utilities likemask-conic-from-*
, or it can be used to provide a complete arbitrary conic mask likemask-conic-[from_78deg,black_25%,transparent_80%]
from
andto
both have defaults so they are both optionalArbitrary masks
mask-*
(e.g.mask-[linear-gradient(to_bottom,black_45%,transparent_65%,black_90%)]
)mask-image
to an arbitrary valueNotes:
mask-image
definition, so it's not composable with other mask utilities