Comments
https://stackblitz.com/edit/nuxt-starter-zb2imp?file=README.md Can you redo everything and post it here and share me ? Thank you |
@productdevbook here's the reproduction - https://stackblitz.com/edit/nuxt-starter-mah2ws?file=app.vue |
|
@productdevbook it works with
|
// tailwind.config.js
your added ? |
I'm using @nuxtjs/tailwindcss module which adds this automatically - https://tailwindcss.nuxtjs.org/ |
https://stackblitz.com/edit/nuxt-starter-6ybojo?file=app.vue it is working ? what not working |
https://stackblitz.com/edit/nuxt-starter-svfhtp?file=app.vue adding new styles to naive-ui components doesn't work, but i think that's fine. |
Hey @productdevbook, I believe this is still not fixed :/ |
|
got the same issue, please reopen this @productdevbook |
overriding tailwindcss default button background solve this, but i dont think we should override every style that conflicting with tailwindcss |
I manage to solve the same issue using vitesse with unocss simply removing the code below from reset/tailwind.css button, [type='button'], [type='reset'], [type='submit'] { This class is generated by tailwind engine and should be removed inside node_modules, now we have to find where tailwind css is located to be able to remove this and fix all the conflict at once. |
To fix this issue: This fixes the issue and also improve performance of tailwind by 20 times |
I'm sorry but that's just not the way to fix this issue. Tailwind classes should still work on NaiveUI components, but NaiveUI components stylesheet should take priority over the default Tailwind stylesheet, which as we've seen, sets the background-color of buttons to transparent. |
related tusen-ai/naive-ui#3733 |
2 options I have for this is:
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:beforeMount', () => {
if (process.server) return;
const naive = document.createElement('meta')
naive.name = 'naive-ui-style'
document.head.appendChild(naive)
})
})
@tailwind base;
@layer base {
button, [type='button'], [type='reset'], [type='submit'] {
background-color: var(--n-color)
}
}
@tailwind components;
@tailwind utilities; |
Sadly those 2 options are not solutions to the problem:
|
okay then another potential solution would be to implement huntersofbook/huntersofbook#1 but alternating from that create a style element with: export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:beforeMount', () => {
if (process.server) return;
const naive = document.createElement('style')
naive.textContent = `
button:is(.n-button),
[type='button']:is(.n-button),
[type='reset']:is(.n-button),
[type='submit']:is(.n-button) {
background-color: var(--n-color)
}`
document.head.appendChild(naive)
})
}) and if you wanna manage that with a plugin, use a runtime config property to set the cls prefix if you've got a naive config with a different cls prefix. |
The real reason is that tailwind has a preset default style of Preflight, which is friendly to new projects, but when we integrate tailwindcss into existing projects, it will cause style conflicts, we only need to disable this tailwindcss Preflight The style settings in your tailwind.config.js or tailwind.config.cjs module.exports = {
corePlugins: {
preflight: false,
}
} Refer to tailwind css official website for explanation: |
@qindongliang thank you yes, thats true fixed. add readme |
https://stackblitz.com/edit/nuxt-starter-pxdal5 check demo settings |
Darwin
v16.14.0
3.0.0-rc.11
0.5.4
yarn@1.22.18
vite
-
-
-
Tailwind overwrites Naive-ui's styles even after following https://www.naiveui.com/en-US/os-theme/docs/style-conflict
The text was updated successfully, but these errors were encountered: