Skip to content

Fix mask axis conflicts and arbitrary stop positions - #748

Merged
dcastil merged 4 commits into
dcastil:mainfrom
Nelmad:bugfix/mask-axis-conflicts
Nov 15, 2026
Merged

dcastil merged 4 commits into
dcastil:mainfrom
Nelmad:bugfix/mask-axis-conflicts

Conversation

@Nelmad

@Nelmad Nelmad commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Mask axis utilities now remove earlier matching edge utilities while preserving independent colors and positions. For example, twMerge('mask-r-to-red-500 mask-x-to-blue-500') returns mask-x-to-blue-500; reversing the order preserves both classes so the right edge can refine the axis.

Adds eight directional conflict rules for the x/y axes and mask-specific arbitrary-position validators. The validators are necessary because values such as [20px] and (--position) previously fell into color groups, so the new axis conflicts would otherwise remove independent edge colors. Lengths, numbers, angles, and non-color functions remain positions; named colors, hex colors, color functions, and color: variables remain separate.

Includes regression coverage for both edges, reverse ordering, independent stops/values, arbitrary values/variables, variants, and important modifiers. Updates API and behavior documentation and the configurator's 13 emitted-module snapshots.

Fixes #746, #747.

Validation:

  • pnpm lint
  • pnpm test:types
  • pnpm test β€” 658 tests passed across 79 files, including Vite and Next.js integration tests
  • pnpm --filter tailwind-merge build
  • pnpm --filter tailwind-merge test:exports β€” CJS, ESM, ES5, and TypeScript 3.8 declaration compatibility

Moves the descriptions of `isArbitraryMaskPosition` and `isArbitraryVariableMaskPosition` into the arbitrary value and arbitrary variable validator tables, so they follow the same structure as the other validators instead of trailing paragraphs.

Drops the mask examples from the features page. Mask axis conflicts and stop positions are too specific to feature there, so the docs example count goes back to its previous value.
@codspeed

codspeed Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ Upgrade your CodSpeed plugin for Node.js 24

@codspeed/* 5.7.1 is only tested on Node.js 18, 20, and 22, so your Node.js 24 measurements may be inaccurate. Upgrade your @codspeed/* packages to 6.0.0 or later.

See affected benchmarks

βœ… 7 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing Nelmad:bugfix/mask-axis-conflicts (0842525) with main (174207e)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

…idators

The mask position validator had its own copy of the color function regex because the shared `colorFunctionRegex` missed Tailwind's `--alpha()` and only matched lowercase function names. Both gaps also affected the length validator: `twMerge('text-[--alpha(red/50%)] text-lg')` and `twMerge('text-[RGB(0_0_0/50%)] text-lg')` read the color as a font size and dropped it, because the percentage inside matched as a length.

Adds `--alpha` and case-insensitive matching to `colorFunctionRegex` and lets the mask validator reuse it, so there is a single list to extend when new color functions come up. Adds regression tests for `--alpha()` and uppercase color functions next to the other color-function tests, and notes the shared list in the agent docs.
The note said later edge classes "remain refinements" of an earlier `mask-x-*` or `mask-y-*` class. That only holds for stop positions. For stop colors, Tailwind emits the axis rule after the edge rule, the same way it does for `border-x-*` and `border-r-*` colors, so the axis color applies regardless of class order. Keeping both classes is still the right merge result, but the note should not suggest the edge color wins.

@dcastil dcastil left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR! Looks good, I only added some minor tweaks.

@dcastil
dcastil merged commit b6569fd into dcastil:main Nov 15, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown

This was addressed in release tailwind-merge@3.7.0-dev.b6569fd8bc74a4cdcf92989bc942c24de38ba2a8.

@github-actions

Copy link
Copy Markdown

This was addressed in release tailwind-merge@3.7.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working context-v3 Related to tailwind-merge v3 tailwind-merge

Projects

None yet

2 participants