-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flickers from default TailwindCSS styling #249
Comments
@Destaq Thanks for reporting. I will look at it today. |
@Destaq I added a |
@Destaq I'm closing this and I will follow the issue you opened on |
@saadeghi Reopening this as I've found a significant issue when using The problem is with supporting multiple themes. It only occurs when you have a <script>
export default {
setup() {
useMeta({
htmlAttrs: {
"data-theme": "retro"
}
})
},
};
</script> then there will be a flicker from the default DaisyUI styling (either dark or light mode, depending on the system), to the chosen theme. The library is immediately used, but it utilizes one of these two things before flickering to the right theme. Of course, this can be changed by manually setting the <script>
import { useCookie } from "#app";
export default {
setup() {
const theme = useCookie("theme") || "garden";
useMeta({
htmlAttrs: {
"data-theme": theme,
},
title: "My Nuxt App",
});
return { theme };
},
};
</script> Any tips to get this working with no flicker? |
This only occurs when Server-Side-Rendering is set to true (the default). The following import { defineNuxtConfig } from 'nuxt3'
export default defineNuxtConfig({
build: {
postcss: {
postcssOptions: {
plugins: {
tailwindcss: {},
autoprefixer: {},
}
}
},
},
ssr: false,
}) But this is far from an ideal solution, only sharing in case it helps find the root cause of the problem. Any DaisyUI workaround with SSR would be much appreciated. |
I did some tests. [data-theme="retro"]{
background-color: black;
} And when I refresh pages on Chrome and FireFox, I see flicker of a white page before it gets black. (Safari is fine) :root{
background-color: black;
} And I refresh the page, there's no flicker, page is black in every millisecond. It looks like Chrome and Firefox are reading attribute selector styles slower than other element selectors 🤔 |
Also this code will show yellow flicker before it turns black. but it should simply show black color with no delay. :root{
--color: yellow;
}
[data-theme="retro"]{
--color: black;
}
:root{
background-color: var(--color);
} I guess the problem is performance of attribute selectors on Chrome and Firefox. |
Just for-the-record: I am currently experiencing a comparable issue using
and Hugo (no JavaScript libraries or Frameworks involved; same effect when JS is disabled). Will try to produce an easy-to-follow setup to make it easier to reproduce the issue. |
A bit more information: I guess this issue is not related to daisyUI. I am able to reproduce it on nearly every website using Tailwind as well as on a simple local site under following condition:
Examples on tailwindui.com as well as a local Hugo experiment with daisyUI (cf. comment above): Reloading a website is more likely to trigger the effect than opening the website the first time. As NoScript had trouble with Googles DeclarativeNetRequest API (like others), there might be some CSS magic which is simply getting to slow when these kind of extensions are involved. However, I can reproduce some slightly comparable issues on other website but only Tailwind based are this recognizable due to the default color scheme. Even though it's an edge case: Maybe one can find a way to make the default style flicker less recognizable? |
I agree this is not a problem from daisyUI because daisyUI is just a plugin that adds component class names to a Tailwind CSS build and at the end, it's up to the framework how to handle CSS (load it as a file or not/ load it before JS files, or inside JS or after JS render) One way would be separating critical style (that is needed in the first view) and load them before first before any JS. But there's a big issue about that: CSS specificity. If it's a separate file or inline CSS it will mess with Tailwind's order of class names because it's important what class name comes first in a utility-first library. I think it's better to move this issue to discussions. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
The default TailwindCSS theme is applied for some time, even on a production build, when using DaisyUI.
I believe this is due to upgrading to Nuxt-Bridge and thus slightly changing the way in which TailwindCSS is imported.
You can see a minimum reproducible example here, by going to the examples/nuxtjs section.
Screen.Recording.2021-10-16.at.11.39.21.AM.mov
The text was updated successfully, but these errors were encountered: