Fix lowercase+uppercase keys (camelCase/PascalCase) unexpectedly treated to kebab-case when using JavaScript config file#18115
Closed
woohm402 wants to merge 1 commit intotailwindlabs:mainfrom
Closed
Conversation
10ebcb2 to
adb9580
Compare
Contributor
Author
|
I haven’t thoroughly tested all possible edge cases, so there might be scenarios I missed. |
Contributor
|
I can see two potential issues with this approach:
@theme {
--color-light-green: #0000ff;
}I'd now be able to write either
export default {
theme: {
extend: {
lightGreen: "#0000ff"
},
},
}The suggested color would still be |
Contributor
|
I went with a different approach due to the above points but def appreciate the PR! |
pull bot
pushed a commit
to steinsi/Tailwind
that referenced
this pull request
Nov 21, 2025
…bs#19337) Fixes tailwindlabs#18114 Closes tailwindlabs#18115 This PR changes JS config handling such that we always preserve casing for theme keys (when possible). Now there are *two* exceptions to this rule: 1. Top-level keys in the theme *do* get converted to kebab-case. As CSS variables are not generated from these this shouldn't be a big issue. All of our internal plugins look for kebab-case keys. So, for example, take the path `backgroundColor.red.500`. This must translate to `--background-color-red-500`. But if you had something like `backgroundColor.lightBlue` it would be perfectly fine for that to translate to `--background-color-lightBlue` internally (and thus the utility be written as `bg-lightBlue`. 2. Tuple object keys are converted to kebab-case as well. These keys are converted to "nested" key syntax internally and typtically represent CSS property names. For example: ```js export default { theme: { fontSize: { xs: ["1.5rem", { lineHeight: "1.3" }] }, fontFamily: { sans: ["Potato Mono", { fontVariationSettings: '"XHGT" 0.7' }] } } } ``` The `lineHeight` key here must be converted to `line-height` because it represents a CSS property name. The theme key that represents this value is `--text-xs--line-height`. The same situation applies for the `fontVariationSettings` where the theme key is `--font-sans--font-variation-settings`.
Contributor
Author
|
@thecrypticace Ah, got it. Thanks for the clarification! |
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
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.
Summary
Fixes #18114.
It Seems in
apply-config-to-theme.ts#keyPathToCssPropertyfunction the theme key is transformed as:.is replaced with-/([a-z])([A-Z])/is replaced with$1-$2.toLowerCase()However in
theme.ts#resolve, when failed to find exact key, it only replaces.is replaced with-It seems the second transformation step is missing in theme.ts#resolve, causing inconsistencies when using camelCase or PascalCase theme keys.
Test plan
All unit tests pass, including the new test case covering this behavior.