Skip to content
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

Document how to add React Bootstrap #301

Closed
gaearon opened this issue Jul 30, 2016 · 19 comments
Closed

Document how to add React Bootstrap #301

gaearon opened this issue Jul 30, 2016 · 19 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Jul 30, 2016

This comes up fairly often.

Unlike React Router, it is not immediately obvious how to add React Bootstrap because it needs its own CSS. So I think it’s worth documenting this here (even though we won’t document adding e.g. the router) because this is a super common use case for beginners.

@manavsehgal
Copy link
Contributor

Here's how I got React Bootstrap working at https://github.com/manavsehgal/react-eshop (Create React App scaffolded app).

Step 1. Install React Bootstrap and Bootstrap from NPM.

npm install react-bootstrap --save
npm install bootstrap --save

Step 2. Import Bootstrap CSS and optionally Bootstrap theme CSS in the index.js file.

import './index.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';

Step 3. Import required React Bootstrap components within App.js file or your custom component file.

import React, { Component } from 'react';
import { Navbar, Jumbotron, Button } from 'react-bootstrap';

Now you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example App.js redone using React Bootstrap.

@gaearon
Copy link
Contributor Author

gaearon commented Jul 31, 2016

Nice, would you like to contribute this to template/README.md?

@manavsehgal
Copy link
Contributor

Thx, will do.

@tonyfreelance
Copy link

Thanks @manavsehgal! It worked smoothly!

@gaearon gaearon closed this as completed Aug 1, 2016
@Oxyrus
Copy link

Oxyrus commented Jan 11, 2017

The provided App.js doesn't show how to work with bootstrap anymore.

@tbillington
Copy link

tbillington commented Jan 11, 2017

@Oxyrus I think it's on purpose, there is a section of the readme that covers how to add it.

@gaearon
Copy link
Contributor Author

gaearon commented Jan 11, 2017

Adding Bootstrap

@ShashankaNataraj
Copy link

@gaearon How about yarn instructions? Are they reqd? Or just overkill?

@gaearon
Copy link
Contributor Author

gaearon commented Feb 24, 2017

@ShashankaNataraj I don't think we need Yarn instructions everywhere. I would suggest any Yarn user to also learn the same npm commands.

@camachon18
Copy link

Extremely helpful for beginners! Thanks @manavsehgal 👍

@MuneebJS
Copy link

MuneebJS commented Sep 7, 2017

greate work like a charm...
thank you so much

@Meghajit
Copy link

Meghajit commented Nov 8, 2017

Wow..It worked

@Atlas7
Copy link

Atlas7 commented Nov 16, 2017

Life saver. Thank you! This Medium article has also helped me out with Webpack config in conjunction to react-bootstrap setup.

@ldelossa
Copy link

Can anyone help me (noob here) understand why the css imports have to be done in index.js ? Why does it not work in App.js?

@saranshbansal
Copy link

The method described by @manavsehgal only works for bootstrap v3 not v4.
Can anyone provide a solution to run bootstrap v4 with react 16?

@internet-john
Copy link

internet-john commented Mar 26, 2018

@saranshbansal I'd recommend locking bootstrap on 3.3.7 to unblock yourself

@ghost
Copy link

ghost commented Aug 13, 2018

Module not found: Can't resolve 'bootstrap/dist/css/bootstrap-theme.css' in 'C:\reactApps\loginpage\src'

@kaoussi
Copy link

kaoussi commented Oct 22, 2018

@arpeetgautam that's because Bootstrap version four doesn't have the bootstrap theme css included when downloaded via npm

@AndrewLamYW
Copy link

AndrewLamYW commented Dec 24, 2018

The method described by @manavsehgal only works for bootstrap v3 not v4.
Can anyone provide a solution to run bootstrap v4 with react 16?

The documentation has been updated with Bootstrap v4
https://facebook.github.io/create-react-app/docs/adding-bootstrap

@lock lock bot locked and limited conversation to collaborators Jan 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests