Replies: 40 comments 41 replies
-
Settings |
Beta Was this translation helpful? Give feedback.
-
Can you explain the problem more clearly and show the old behavior compared to the new behavior so we can understand what has actually changed for you? |
Beta Was this translation helpful? Give feedback.
-
When I upgrade 3.0.0-alpha.1 Default base button style like if Settings |
Beta Was this translation helpful? Give feedback.
-
Looks like you have your CSS in a bad order — you should make sure your The order needs to be like this: @tailwind base;
@tailwind components;
.n-button { /* ... */ }
@tailwind utilities; Giving you control over this order is the reason Tailwind provides three layers for the styles. Those styles are there in v2 as well, just organized very slightly differently but not in a way that should impact this: https://unpkg.com/tailwindcss@2.2.19/dist/base.css Going to convert this to a help discussion, but if there is a real issue here that I'm missing (there totally could be, sorry if so!) please open a new issue and follow the issue template, including providing a proper reproduction repository. |
Beta Was this translation helpful? Give feedback.
-
I upgraded to 3.0 and the background colors on my MUI Button component went transparent. I don't want to completely disable the preflight. How can I only disable the button > background-color: transparent? |
Beta Was this translation helpful? Give feedback.
-
I have the same problem, but only when building my react app. Everything works when using development build. |
Beta Was this translation helpful? Give feedback.
-
I also noticed this change, it looks to just be an update to the reset in V3 that now sets the background color to be transparent. My fix was to just switch the order of imports and make sure my (legacy) custom CSS was imported after Tailwind so that it won. |
Beta Was this translation helpful? Give feedback.
-
Same problem with element-plus. |
Beta Was this translation helpful? Give feedback.
-
I also encountered this problem, I hope there will be a solution |
Beta Was this translation helpful? Give feedback.
-
I make several ways to solve problem. If you have installed
Temporary SolutionNow, you need get ready with these files:
Edit your html as below, <!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Your site title</title>
</head>
<body>
<div id="app"></div>
<!-- <script type="module" src="/src/tailwindcss.ts"></script> -->
<script type="module" src="/src/main.ts"></script>
</body>
</html> Remeber a bit modify with main.ts import "@/assets/styles/index.scss"; Here is my @import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
// other basic style your project needs
@import './transition.scss';
/**
* element plus style reset
*/
.el-popper {
max-width: 480px;
} Most important one with import { resolve } from "path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import analyze from "rollup-plugin-visualizer";
export default defineConfig({
plugins: [
vue(),
AutoImport({
resolvers: [ElementPlusResolver()],
}),
Components({
resolvers: [ElementPlusResolver()],
}),
],
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
build: {
rollupOptions: {
plugins: [analyze()],
output: {
manualChunks(id) {
// 更新日期:2022年06月09日
// 下面这三行css代码打包的配置可以随你移除或者保留~移除后会自动生成一个css,和下面的示例图会有区别。
if (id.includes("assets/styles/index.scss")) {
return "tailwindcss";
}
if (id.includes("element-plus/theme-chalk/")) { // 当然也可以优化下这个判断,不过目前这样写足矣了。
return "element-plus";
}
},
},
},
},
server: {
proxy: {
"/api": {
target: "http://x.x.x.x:xx",
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, "/api"),
},
},
},
}); Please keep eyes on
At last, I need to show what I have researched for this problem, vite has lots of issues about this similar questions, such as:
It seems that will be fixed sooner or later. And my solution mostly inspired by vitejs/vite#6375 relative issues: #6602 我目前有几个办法来解决。当前我使用的是
Even though solve the button style, but conflict still there, so I think we should make sure keep tailwindcss style first, and do not modify it, espacially disable preflight. Try to let other style(maybe UI framework) override it. |
Beta Was this translation helpful? Give feedback.
-
I solved this creating custom classes with For someone like me that haved this problem ;) |
Beta Was this translation helpful? Give feedback.
-
Excluding classes may be the solution. (May not be applicable for different scenarios) Example: button:not(.x-class, .y-class, .z-class),
[type='button']:not(.x-class, .y-class, .z-class),
[type='reset']:not(.x-class, .y-class, .z-class),
[type='submit']:not(.x-class, .y-class, .z-class) {
-webkit-appearance: button; /* 1 */
background-color: transparent; /* 2 */
background-image: none; /* 2 */
} I have no solution for this situation other than manually editing the generated css! I'm sure a lot of people will be pleased if a solution can be found to this. |
Beta Was this translation helpful? Give feedback.
-
I can assure that the same issue still happens with MUI in the current version of tailwind (3.1.2). I don't want to disable the preflight interely because the missing of the default styles breaks most of the application. Does anyone discovered a way to safely disable/override the default button style? |
Beta Was this translation helpful? Give feedback.
-
Even i faced the same issue but I am using
but this is kinda "hack", this either need to be fixed by UPDATE:
|
Beta Was this translation helpful? Give feedback.
-
This is also breaks the AntDesign component library. Sad that this has been an issue for so long without being addressed. |
Beta Was this translation helpful? Give feedback.
-
It works! tailwind.config.cjs /** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
corePlugins: {
preflight: false,
}
} |
Beta Was this translation helpful? Give feedback.
-
I noticed that you are having the same problem as mine, you are using the Naive UI framework, to fix this, in your main.js (where you initialize Vue) add this: |
Beta Was this translation helpful? Give feedback.
-
I am using Nuxt 3 with Naive UI and I "fixed" this using import replace from 'vite-plugin-filter-replace'
export default defineNuxtConfig({
modules: [
'@nuxtjs/tailwindcss',
'@bg-dev/nuxt-naiveui',
],
vite: {
plugins: [
replace([{
// Fixes issue with Tailwind preflight where Naive UI buttons were transparent
filter: ['node_modules/tailwindcss/tailwind.css'],
replace: source => source.replace(/(background-color: transparent;)/, '/* $1 */'),
}]),
],
}
}) |
Beta Was this translation helpful? Give feedback.
-
Not an ideal solution but I've temporarily got it working with inline styles. Hoping for a fix to be able to disable preflight buttons only as an option.
|
Beta Was this translation helpful? Give feedback.
-
I ended up adding a new button class .button-primary {
background-color: #1F883D;
} and apply to my button: <button className="button-primary"></button> which overwrites the default transparent background color. |
Beta Was this translation helpful? Give feedback.
-
Spent 4 hours arguing with chatgpt about this and decided to ask google and found you guys talking about this, after deciding to do something not recommended, I just changed the color after inspecting it and recognizing the issue is this transparent class tailwind.css1 ~/public/build/assets/app-375e9f6d.css
to
just changed the color, and it seems to work fine - I am just learning all this it's all new to me. Any feedback would be greatly appreciatted. |
Beta Was this translation helpful? Give feedback.
-
I am a bit shocked that this issue is not yet resolved, as it screws with many frontend frameworks... For anyone coming here in the future, I recommend the following, as it's the least amount of work to do:
/** @type {import('tailwindcss').Config} */
export default {
content: ["..."],
corePlugins: {
preflight: false,
},
theme: {},
plugins: [],
}
button,
[type='button'],
[type='reset'],
[type='submit'] {
-webkit-appearance: button; /* 1 */
/* background-color: transparent; 2 */
/* background-image: none; 2 */
}
@import "preflight.css";
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
@import "other css files" |
Beta Was this translation helpful? Give feedback.
-
For those wondering is causing this, it is most likely a a package that you installed has globals styles that override the tailwind global CSS. In my case it was the ProseMirror package |
Beta Was this translation helpful? Give feedback.
-
I am using Vite. So i just use plugins: [
{
name: 'remove-button-bg-reset',
transform(src, id) {
if (id.includes('@unocss/reset/tailwind.css')) {
return {
code: src.replace(/(background-color:\s?transparent;)(.*\n?\s*)(background-image:\s?none;)/, '/* $1 */$2/* $3 */ '),
}
}
},
},
] |
Beta Was this translation helpful? Give feedback.
-
I can confirm the issue is still there and makes Antd and Tailwind incompatible! Any provided solution is basically a hack. Hope this gets fixed asap |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
a PR to fixing this was merged. But this fix is still not released. The latest version(3.4.1) for now does not contain this fix. |
Beta Was this translation helpful? Give feedback.
-
God just landed here what's is the problem here i mean why is this not removable @tailwindcss please help damn button, [type='button'], [type='reset'], [type='submit'] |
Beta Was this translation helpful? Give feedback.
-
We've reduced the specificity of these selectors in Tailwind CSS v3.4.2: Still stand by comments I've made in other discussions about how there will inevitably be conflicts you have to workaround when importing two CSS frameworks into the same project, but those changes should at least help a bit in this case. |
Beta Was this translation helpful? Give feedback.
-
Hello, I followed the tailwind documentation about setting up a global.css file with :
What should I do to have my
not being overriden by
? My component:
The behavior: Edit: |
Beta Was this translation helpful? Give feedback.
-
How to remove this default style Now it's affecting This kind of writing
background-color: var(--color)
tailwindcss The weights are higher than himBeta Was this translation helpful? Give feedback.
All reactions