Issue
I am using Tailwind CSS and Bootstrap (ngx-bootstrap) in the same Angular project. For the most part, they play along nicely. However, when it comes to padding and margins, they fight like siblings. I want to use Tailwind for padding because it is consistent. For example, the class p-X
is X times 0.25 rem but with bootstrap, it is all over the place. The annoying thing is that Bootstrap puts !important
everywhere.
utilities.css
comes from Tailwind and _spacing.scss
comes from Bootstrap.
Is there a convenient way to solve this?
Solution
The best practice to avoid naming conflicts with Tailwind utility classes is using prefix
option on your tailwind.config.js
file.
module.exports = {
prefix: 'tw-',
}
But if you want only to put !important
rule for Tailwind classes, and you have already control the order of css code (tailwind classes are the last), you can set the important
option to true on the tailwind config file.
module.exports = {
important: true,
}
Make sur to not override tailwind classes when you're choosing to set the important
option only, see What is the order of precedence for CSS?
Answered By - BENMEDDAH Mohamed Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.