-
-
Notifications
You must be signed in to change notification settings - Fork 51.7k
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
New ant design version 5.0.0 is confilicting with tailwindcss #38794
Comments
Hello @rizwan92. Please provide a online reproduction by forking codesandbox of antd@5.x or antd@4.x, or provide a minimal GitHub repository. Issues labeled by 你好 @rizwan92, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击这里创建一个 antd@5.x 或 antd@4.x 的 codesandbox,或者提供一个最小化的 GitHub 仓库。3 天内未跟进此 issue 将会被自动关闭。 |
reproduction link added |
This comment was marked as outdated.
This comment was marked as outdated.
yes @li-jia-nan's solution is working for me previous version and after migrating to new 5.0 version still working |
It's not issue with antd since tailwindcss's preflight override the style of Button. The priority of css selector are the same. |
@li-jia-nan preflight: false tailwind border not working and may more feature not working in tailwind and one more thing as you can see my primary colour is different in the antd config provider in the reproduction link but form input element has blue border color when we focus on it |
Same problem here ! Can you please reopen the issue @MadCcc ? |
reopen |
facing the same issue |
@li-jia-nan we need a patched update soon! |
Ohhh! I fixed this issue by using StyleProvider, it work like a charm: <ConfigProvider
theme={{
token: {
colorPrimary: "#000",
},
}}
>
<StyleProvider hashPriority="high">
<RootApp />
</StyleProvider>
</ConfigProvider> My Reproduction link demo: |
Yes, this could help solve the problem by raise the priority of antd's selector. Since we do not have better solution for mixed style with tailwindcss, this may be the most suitable way to fix it. But you should be aware of the high priority brought by hash class, it may cause some other effect in style. Ref: https://ant.design/docs/react/customize-theme#compatible-adjustment Going to close this issue with possible solution. Feel free to open new issue if encounter with other problems. |
Though the |
The |
Any updates? |
One way is to configuration Important of Tailwind CSS, let Tailwind CSS a higher priority. // tailwind.config.js
module.exports = {
// ...other
corePlugins: {
// Remove Tailwind CSS's preflight style so it can use the antd's preflight instead (reset.css).
preflight: false
},
important: '#app',
// ...other
} // pages/_document.tsx or app/layout.tsx
<body id="app">
...
</body> /* globals.css */
@import 'antd/dist/reset.css';
// fix Tailwind CSS border styles,form Tailwind CSS's preflight
*,
::before,
::after {
box-sizing: border-box; /* 1 */
border-width: 0; /* 2 */
border-style: solid; /* 2 */
border-color: theme('borderColor.DEFAULT', currentColor); /* 2 */
}
::before,
::after {
--tw-content: '';
}
@tailwind base;
@tailwind components;
@tailwind utilities; |
Thanks, bro it is really working for me. |
@Vincz what's going on with you ? |
@KhokharJunaid keep in mind that disabling preflight is not a good idea, because you must be re-develop base styles global when preflight disabled. |
|
doesn't work? can you give me reproduction link? |
Hi, pls confirm with |
So is there an optimal solution? i use antd@5.7.2 and tailwindcss@3.3.2👀 |
I have made a postcss plugin postcss-antd-fixes tries to process conflicts of antd with any others global CSS reset, support TailwindCSS for now. Online example: https://stackblitz.com/edit/postcss-antd-fixes?file=postcss.config.js 20230924 UpdateI just found that there is also a anchor style conflict, antd will generate link style like this And tailwind has related anchor reset css: https://github.com/tailwindlabs/tailwindcss/blob/b33c30284f8a857a94c5dece88d489a7589dfaf6/src/css/preflight.css#L88 a {
color: inherit;
text-decoration: inherit;
} So I add new fix function to resolve it, make anchors style under any antd components normal as expected, online example updated. |
any updates on this issue? |
1 similar comment
any updates on this issue? |
FYI, There is a anchor style conflict to be fixed. |
Hi, @yunsii May I know if you fixed this anchor style conflict? |
@EdwardMoMo As a non-native English speaker, maybe my expression is not clear? I had fixed and released with postcss-antd-fixes@0.2.0 |
Great, thanks, I noticed the new commit of your plugin. |
guys
this one is working perfectly. no need to disable tailwindcss's preflight. Also, disabling preflight is not recommended.It can be affect to native tailwind style |
This worked for me well. |
I gave up after trying everything for fixing my button color. I went with this in global.css
|
maybe me too |
Thank you, it is working for me. Saving my life. |
While going through this thread and exploring different options to configure Tailwind CSS with AntD V5, I finally found the official solution on the AntD website. This solution of AntD website worked best for me. Hope this helps other people too! |
Also I have updated my postcss plugin docs: https://github.com/yunsii/postcss-antd-fixes#features |
It is working perfectly for me, thank you! |
Does anybody have a luck to make it work with Tailwind CSS 4 (+ lightning css, ideally)? |
@anotheri try replace @layer theme, base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);
@import 'tailwindcss/preflight.css' layer(base);
// put @tailwind utilities in #app or other selectors
#app {
@tailwind utilities;
} then u can see it works <Button className='hidden'>start</Button> |
|
@liaoyinglong yeah, i've also noticed last week that it seems to be working as expected (after a couple updates of Vite, postcss so most probably it was not directly related to antd), thanks for heads up anyways. |
Refer to [the doc file](https://ant.design/docs/react/compatible-style#tailwindcss-arrange-layer) of Antd, the `tailwind.css` file content need some modifies. The related issue of antd for refrerence. ant-design/ant-design#38794 (comment)
Reproduction link
code sandbox reproduction
Steps to reproduce
<Button type="primary> Button button primary is not working
What is expected?
Button primary should work
What is actually happening?
Button Primary is not right output
please fix it
The text was updated successfully, but these errors were encountered: