I was using Modal
of semanctic-ui-react
inside a create-react-app
project. Inside index.js
I had declared the import for the CSS files of the frameworks
import "semantic-ui-css/semantic.min.css"
import "bootstrap/dist/css/bootstrap.css"
I noticed the weird positioning of Modal. After debugging I found a .modal
CSS class was getting applied which was coming from the Bootstrap's
CSS. Since semantic-ui
also has the similar name classes, this caused the overlapping.
On removing the import "bootstrap/dist/css/bootstrap.css"
, Modal get positioned correctly.
Solution(partial) in my mind:
import CSS file only in the class where it has been used, and not to the index.js
-this has two problems:
1. Suppose EditForm.js
uses semantic-ui
, I import the semantic.min.css
directly in this file. But what if it's parent class in which
EditForm.js
is used, if parent.js
is using bootstrap.css
then again
the same problem will occur.
2. I am not sure on this, but importing the complete CSS seperately for each files could make those files heavy, please correct me here.
I want to use both the frameworks in my project, what would be the ideal way?