Skip to content

Conversation

@nlemoine
Copy link
Contributor

Theme colors defined with dashes in nested objects (e.g.,
{ brand: { 'dark-blue': '#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 #4770

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
@nlemoine nlemoine requested review from antfu and zyyv as code owners December 17, 2025 18:10
@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c92eb08
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/6945703ffc5d9b0009c99307
😎 Deploy Preview https://deploy-preview-5021--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 18, 2025

Open in StackBlitz

commit: c92eb08

Comment on lines 52 to 54
brand: {
'dark-blue': '#123456',
},
Copy link
Member

Choose a reason for hiding this comment

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

brand: {
  'dark-blue': {
    DEFAULT: '#123456',
    'foo-bar': {
      baz: '#fff'
    }
  },
},

Can you help test more complex test cases?

Copy link
Contributor Author

@nlemoine nlemoine Dec 19, 2025

Choose a reason for hiding this comment

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

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 zyyv merged commit 8e7db6e into unocss:main Dec 22, 2025
9 of 11 checks passed
@nlemoine
Copy link
Contributor Author

thanks @zyyv !

@nlemoine nlemoine deleted the fix-nested-dashed-theme-keys branch December 22, 2025 16:55
This was referenced Dec 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[presetWind3] Theme object syntax extends does not support variables with - (dash) in runtime

2 participants