/ tailwindcss Public
Allow merging of arrays with objects when using extend #2700
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.
Currently we have the ability to use the
extendkeyword in our theme config:
We introduced automatic deep-merging for Tailwind 2.0; The expected output of that snippet above means that a new color for red will be added, but the other colors (100 - 900) still exist. The deep merging of objects works as expected.
We currently also have an exception to this rule, for example when you look at the fontFamily, the values of each font is an array. This means that if you want to set the
sansfont family to something completely different, you can do it by changing the array. Note that the extend functionality does not merge arrays.
But here is an issue I faced while working on the
typographyplugin. In the typography plugin we do have an array with default values, and we can extend those values. Each "value" in the array is an object. The reason why is so that we can do something like this:
The issue now is that we don't merge arrays, in other words, it is impossible to extend the typography styles without a breaking change.
This PR makes a few assumptions, but I think that those assumptions are ok.
What this PR does: