Skip to content
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

Button组件的样式会与tailwindcss的preflight冲突 #759

Open
1 task done
Xy2002 opened this issue Mar 2, 2022 · 9 comments
Open
1 task done

Button组件的样式会与tailwindcss的preflight冲突 #759

Xy2002 opened this issue Mar 2, 2022 · 9 comments
Assignees
Labels
has: PR Has pull request status: 💬 discussion Some problems have not come to a definite conclusion type: 🐞 bug Something isn't working type: enhancement feature enhancement

Comments

@Xy2002
Copy link

Xy2002 commented Mar 2, 2022

基本信息

预期结果

希望能解决与tailwindcss的样式冲突

复现步骤

当Button组件的type为primary且没有设置status时,tailwindcss的preflight会将组件type=primary预设的样式覆盖为background-color:transparent,但设置status时,显示正常

@xuxucode
Copy link
Contributor

xuxucode commented Mar 3, 2022

<a-form-item required> 有类似情况,* 号会显示在 label 上方:

image

@xuxucode
Copy link
Contributor

xuxucode commented Mar 5, 2022

tailwindcss preflight 基于 modern-normalize 添加了 button、svg 等样式,arco 基于 normalize.css,两者冲突和多余,禁用 preflight 后就好了:

// tailwind.config.js
module.exports = {
+  corePlugins: {
+    preflight: false,
+  },

然而 preflight 中的有些样式还是必要的,比如 border-style,需要手动添加,否则 class="border" 不起作用。

@IsLand-x
Copy link
Contributor

IsLand-x commented Mar 5, 2022

image
可以这样改一下源码,提高权重。

@Xy2002
Copy link
Author

Xy2002 commented Mar 6, 2022

tailwindcss preflight 基于 modern-normalize 添加了 button、svg 等样式,arco 基于 normalize.css,两者冲突和多余,禁用 preflight 后就好了:

// tailwind.config.js
module.exports = {
+  corePlugins: {
+    preflight: false,
+  },

然而 preflight 中的有些样式还是必要的,比如 border-style,需要手动添加。

后续发现调换import顺序就好了。如果直接禁用tailwindcss preflight会导致我的项目需要大量修改样式

// src/main.ts
import './index.css' //tailwindcss directives
import '@arco-design/web-vue/dist/arco.css'

@IsLand-x
Copy link
Contributor

IsLand-x commented Mar 6, 2022

tailwindcss preflight 基于 modern-normalize 添加了 button、svg 等样式,arco 基于 normalize.css,两者冲突和多余,禁用 preflight 后就好了:

// tailwind.config.js
module.exports = {
+  corePlugins: {
+    preflight: false,
+  },

然而 preflight 中的有些样式还是必要的,比如 border-style,需要手动添加。

后续发现调换import顺序就好了。如果直接禁用tailwindcss preflight会导致我的项目需要大量修改样式

// src/main.ts
import './index.css' //tailwindcss directives
import '@arco-design/web-vue/dist/arco.css'

这样做是引入全量样式,项目体积会变大吧?

@Xy2002
Copy link
Author

Xy2002 commented Mar 7, 2022

tailwindcss preflight 基于 modern-normalize 添加了 button、svg 等样式,arco 基于 normalize.css,两者冲突和多余,禁用 preflight 后就好了:

// tailwind.config.js
module.exports = {
+  corePlugins: {
+    preflight: false,
+  },

然而 preflight 中的有些样式还是必要的,比如 border-style,需要手动添加。

后续发现调换import顺序就好了。如果直接禁用tailwindcss preflight会导致我的项目需要大量修改样式

// src/main.ts
import './index.css' //tailwindcss directives
import '@arco-design/web-vue/dist/arco.css'

这样做是引入全量样式,项目体积会变大吧?

是的,但是因为是不那么重要的项目,所以怎么方便怎么来🤣,不是特别需要考虑项目体积

@hyp530
Copy link

hyp530 commented Jun 5, 2022

请问,使用unplugin-vue-components按需引用arco,normlize.css污染了整体样式,怎么降低normlize.css的优先级呢?

@xuxucode
Copy link
Contributor

xuxucode commented Jun 6, 2022

@flsion 在 tailwindcss 越来越流行的情况下,建议 arco-design 替换掉 normlize.css 而使用 modern-normalize,两者保持更好的兼容性。

@flsion
Copy link
Member

flsion commented Jun 10, 2022

@flsion 在 tailwindcss 越来越流行的情况下,建议 arco-design 替换掉 normlize.css 而使用 modern-normalize,两者保持更好的兼容性。

好的,我来调研一下看看

@flsion flsion self-assigned this Jun 10, 2022
@flsion flsion added the type: enhancement feature enhancement label Jun 10, 2022
@hehehai hehehai added status: 💬 discussion Some problems have not come to a definite conclusion type: 🐞 bug Something isn't working has: PR Has pull request labels Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has: PR Has pull request status: 💬 discussion Some problems have not come to a definite conclusion type: 🐞 bug Something isn't working type: enhancement feature enhancement
Projects
None yet
Development

No branches or pull requests

6 participants