Getting Started with React Bootstrap


Learn how to include React Bootstrap in your project


The best way to consume React-Bootstrap is via the npm package which you can install with npm (or yarn if you prefer).

If you plan on customizing the Bootstrap Sass files, or don’t want to use a CDN for the stylesheet, it may be helpful to install vanilla Bootstrap as well.

npm install react-bootstrap bootstrap


Because React-Bootstrap doesn’t depend on a very precise version of Bootstrap, we don’t ship with any included CSS. However, some stylesheet is required to use these components.


{/* The following line can be included in your src/index.js or App.js file*/}

import 'bootstrap/dist/css/bootstrap.min.css';

How and which Bootstrap styles you include is up to you, but the simplest way is to include the latest styles from the CDN.



In case you are using Sass the simplest way is to include the Bootstrap’s source Sass files in your main Sass file and then require it on your src/index.js or App.js file. This applies to a typical create-react-app application in other use cases you might have to setup the bundler of your choice to compile Sass/SCSS stylesheets to CSS.

/* The following line can be included in a src/App.scss */

@import "~bootstrap/scss/bootstrap";

/* The following line can be included in your src/index.js or App.js file */

import './App.scss';

Customize Bootstrap

If you wish to customize the Bootstrap theme or any Bootstrap variables you can create a custom Sass file:

/* The following block can be included in a custom.scss */

/* make the customizations */
$theme-colors: (
    "info": tomato,
    "danger": teal

/* import bootstrap to set changes */
@import "~bootstrap/scss/bootstrap";

… And import it on the main Sass file.

@import "custom";

Advanced usage

See the Bootstrap docs for more advanced use cases and details about customizing stylesheets.


You should import individual components like: react-bootstrap/Button rather than the entire library. Doing so pulls in only the specific components that you use, which can significantly reduce the amount of code you end up sending to the client.

import Button from 'react-bootstrap/Button';

// or less ideally
import { Button } from 'react-bootstrap';

Browser globals

We provide react-bootstrap.js and react-bootstrap.min.js bundles with all components exported on the window.ReactBootstrap object. These bundles are available on unpkg, as well as in the npm package.

<script src="" crossorigin />



<script>var Alert = ReactBootstrap.Alert;</script>


React-Bootstrap has started a repo with a few basic CodeSandbox examples. Click here to check them out.


React-Bootstrap is compatible with existing Bootstrap themes. Just follow the installation instructions for your theme of choice.

Watch out!

Because React-Bootstrap completely reimplements Bootstrap’s JavaScript, it’s not automatically compatible with themes that extend the default JavaScript behaviors.

Create React App

If you would like to add a custom theme on your app using Create React App, they have additional documentation for Create React App and Bootstrap here

#bootstrap #reactjs #web-development #javascript

Getting Started with React Bootstrap
13.15 GEEK