-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add new mask-image utilities for Tailwind CSS v4.1
#17134
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
Merged
Merged
Conversation
This file contains hidden or 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
Member
RobinMalfait
left a comment
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
Member
RobinMalfait
left a comment
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-imageutilities, 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
@propertydeclarations in the prototype are just properties on*instead of using@propertywhich 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:
fromandtoare 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-fromandmask-r-fromat 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%]fromandtoboth have defaults so they are both optionalRadial masks
Radial mask size
mask-radial-*(e.g.mask-radial-[50%_75%])mask-radial-closest-sideclosest-sidemask-radial-closest-cornerclosest-cornermask-radial-farthest-sidefartheset-sidemask-radial-farthest-cornerfarthest-cornermask-radial-closest-cornerclosest-cornerNotes:
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-circlecirclemask-ellipseellipseNotes:
mask-ellipseis the default, so it's only really useful to "undo"mask-circleRadial mask position
mask-radial-at-*(e.g.mask-radial-at-[25%_100px])mask-radial-at-toptopmask-radial-at-top-lefttop leftmask-radial-at-top-righttop rightmask-radial-at-bottombottommask-radial-at-bottom-leftbottom leftmask-radial-at-bottom-rightbottom rightmask-radial-at-leftleftmask-radial-at-rightrightNotes:
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%]fromandtoboth have defaults so they are both optionalArbitrary masks
mask-*(e.g.mask-[linear-gradient(to_bottom,black_45%,transparent_65%,black_90%)])mask-imageto an arbitrary valueNotes:
mask-imagedefinition, so it's not composable with other mask utilities