Adding tailwindcss to my Phoenix project seems to have broken a lot of the styling. For example, here is a button before adding tailwindcss:
and here it is afterwards:
What can I do to get the benefits of tailwind without breaking my existing styling?
The reason that the native Phoenix styles break is because Tailwind comes with Preflight, which is a bunch of default styles. Preflight can conflict with whatever native styling you might have. That's why it broke in my case. I was able to solve this problem by adding:
corePlugins: { preflight: false, },
To module.exports
in tailwind.config.js
. This disables Preflight and lets the native Phoenix styles stay. If you don't need Preflight this is a good choice.