fix(preset-mini): resolve nested theme colors with dashed keys#5021
Merged
Conversation
Theme colors defined with dashes in nested objects (e.g.,
`{ brand: { 'dark-blue': 'unocss#123' } }`) were not resolving at runtime when used as `text-brand-dark-blue`.
The color lookup only tried camelCase conversion (`darkBlue`) but never checked the original dashed form (`dark-blue`).
Closes unocss#4770
✅ Deploy Preview for unocss ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
commit: |
zyyv
reviewed
Dec 19, 2025
Comment on lines
+52
to
+54
| brand: { | ||
| 'dark-blue': '#123456', | ||
| }, |
Member
There was a problem hiding this comment.
brand: {
'dark-blue': {
DEFAULT: '#123456',
'foo-bar': {
baz: '#fff'
}
},
},Can you help test more complex test cases?
Contributor
Author
There was a problem hiding this comment.
Thanks for your review, @zyyv!
I added a more complex test case and refactored the getThemeColorForKey function by borrowing wind4 algorithm.
I posted a similar issue in TW. Since tailwind.config.js (or unocss.config.js) is still supported in TW4, that would make sense to port it to wind3.
Ideally, all theme values should be resolved using that logic, not only colors.
Let me know if you would like to go further.
Theme colors defined with dashes in nested objects were not resolving at runtime. Ported wind4's deepGet algorithm that tries progressively shorter flat keys to find the best match.
Supports complex nesting like:
{ brand: { 'dark-blue': { DEFAULT: 'unocss#123', 'foo-bar': { baz: '#fff' } } } }
Resolves: text-brand-dark-blue, text-brand-dark-blue-foo-bar-baz
Closes unocss#4770
zyyv
approved these changes
Dec 22, 2025
Contributor
Author
|
thanks @zyyv ! |
This was referenced Dec 26, 2025
1 task
This was referenced Dec 26, 2025
This was referenced Dec 28, 2025
This was referenced Jan 14, 2026
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.
Theme colors defined with dashes in nested objects (e.g.,
{ brand: { 'dark-blue': '#123' } }) were not resolving at runtime when used astext-brand-dark-blue.The color lookup only tried camelCase conversion (
darkBlue) but never checked the original dashed form (dark-blue).Closes #4770