Adding Bootstrap

You don’t have to use React Bootstrap together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps:

Install React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well:

npm install --save react-bootstrap bootstrap@3

Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your src/index.js file:

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';
// Put any other imports below so that CSS from your
// components takes precedence over default styles.

Import required React Bootstrap components within src/App.js file or your custom component files:

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.

Using a Custom Theme

Sometimes you might need to tweak the visual styles of Bootstrap (or equivalent package). We suggest the following approach:

  • Create a new package that depends on the package you wish to customize, e.g. Bootstrap.
  • Add the necessary build steps to tweak the theme, and publish your package on npm.
  • Install your own theme npm package as a dependency of your app.

Here is an example of adding a customized Bootstrap that follows these steps.

Updated: