Bruno
Bruno

Reputation: 4665

How to make vanilla Bootstrap work with React on Node?

I don't want to use the react-bootstrap components,

I simply want to use Bootstrap on a React site.

I installed Bootstrap with npm : npm install bootstrap

and added it in my package.json dependencies :

"dependencies": {
    [...],
    "bootstrap": "^3.3.5"
}

and added it to my App.js file : import bootstrap from 'bootstrap';

However, the style is not applied and it looks like a website from 1995.

I also tried to add import bootstrap from 'bootstrap'; to my index.js without success.

What am I missing?

Upvotes: 0

Views: 424

Answers (1)

Jim Skerritt
Jim Skerritt

Reputation: 4596

You also need to add the CSS to your page. You can either:

  • copy bootstrap.css from node_modules/bootstrap/dist/css/, put it in a public folder, and add it to your page normally (which isn't ideal if you ever plan to upgrade bootstrap)

or

  • if you're using something like webpack or gulp, you can just add bootstrap.css to your CSS bundle

Upvotes: 1

Related Questions