unpreset / unocss-preset-theme

The dynamic theme presets for UnoCSS.
https://unocss-preset-theme.todev.cc
123 stars 11 forks source link

Not worked with 'dark' or 'light' class on html attribute #11

Closed Xezard closed 1 year ago

Xezard commented 1 year ago

If you set the theme class ('dark' or 'light') to the html attribute, then the theme is not applied. At the same time, when setting the class to the body attribute, everything works as expected. Due to this problem, the plugin does not work correctly in the nuxt + nuxt-color-mode bundle, since nuxt-color-mode sets the theme class to the html attribute.

Upd: This is due to the fact that the html contains :root with theme variables declared. These variables overwrite variables that are in the class of the selected theme (dark, for example), because of this, changing themes does not work. image

Dunqing commented 1 year ago

Thanks for the feedback, I don't know what nuxt + nuxt-color-mode did, I guess you can set selectors option to avoid :root override .dark

Just like this: selectors { dark: 'html.dark' }

Xezard commented 1 year ago

Thanks for the feedback, I don't know what nuxt + nuxt-color-mode did, I guess you can set selectors option to avoid :root override .dark

Just like this: selectors { dark: 'html.dark' }

image In this configuration, everything began to work exactly as I expected. Thank you so much for your answer!