You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If in nuxt.config.ts the ssr property is set to false, the --ui-* variables cannot be overwritten anymore in :root as described in the nuxt docs here in the green info box: https://ui3.nuxt.dev/getting-started/theme#color-shades.
Only if !important is used, the changes take effect.
I believe this is because the main.css is imported before the variable declaration done by nuxt/ui, so the variable values in main.css are overwritten again. In the final html the --ui-* variable declaration done by nuxt/ui is inlined as the last element in the <head> of the html.
main.css
@import"tailwindcss";
@import"@nuxt/ui";
:root {
/* Try to use different shade. */--ui-primary:var(--ui-color-primary-700); /* Does not work. */--ui-success:var(--ui-color-success-700) !important;
}
nuxt.config.ts
exportdefaultdefineNuxtConfig({devtools: {enabled: true},modules: ["@nuxt/ui"],css: ["~/assets/css/main.css"],compatibilityDate: "2025-01-06",ssr: false,// works if set to true});
@HugoRCD Thanks for looking into it. Is using !important the recommended way to override the variables with ssr: false or can this be fixed in the Nuxt UI module somehow, e.g. by changing the order of the style imports?
Another solution that works for both rendering modes would be to instead override the --ui-* variables on the body tag instead of :root. Due to the higher specifity the overrides on body take precedence over the definitions from Nuxt UI on :root level.
@yschroe As far as I know, there is no recommended way to manage ssr: false, but I will discuss it to potentially find a solution or document a procedure to follow in this case!
The @nuxt/ui CSS variables have been moved into the base layer which fixes the priority. However, you won't be able to only override the :root one because it will also apply to .dark, you will need to override both :root and .dark.
Environment
Is this bug related to Nuxt or Vue?
Nuxt
Version
v3.0.0-alpha.10
Reproduction
https://codesandbox.io/p/devbox/keen-chaplygin-lyj8jq
Description
If in
nuxt.config.ts
thessr
property is set to false, the--ui-*
variables cannot be overwritten anymore in:root
as described in the nuxt docs here in the green info box: https://ui3.nuxt.dev/getting-started/theme#color-shades.Only if
!important
is used, the changes take effect.I believe this is because the
main.css
is imported before the variable declaration done by nuxt/ui, so the variable values inmain.css
are overwritten again. In the final html the--ui-*
variable declaration done by nuxt/ui is inlined as the last element in the<head>
of the html.main.css
nuxt.config.ts
app.vue
The text was updated successfully, but these errors were encountered: