Introduction

    Learn how to include React Bootstrap in your project

    JavaScript

    React-Bootstrap is a complete re-implementation of the Bootstrap components using React. It has no dependency on either bootstrap.js or jQuery. If you have React setup and React-Bootstrap installed you have everything you need.

    Installation

    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

    Importing

    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="https://unpkg.com/react/umd/react.production.js" crossorigin />
    
    <script
      src="https://unpkg.com/react-dom/umd/react-dom.production.js"
      crossorigin
    />
    
    <script
      src="https://unpkg.com/react-bootstrap@next/dist/react-bootstrap.min.js"
      crossorigin
    />
    
    <script>var Alert = ReactBootstrap.Alert;</script>

    Stylesheets

    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. How and which bootstrap styles you include is up to you, but the simplest way is to include the latest styles from the CDN.

    <link
      rel="stylesheet"
      href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
      integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS"
      crossorigin="anonymous"
    />

    For more advanced use cases you can also use a bundler like Webpack or Browserify to include the css files for you as part of your build process but that is beyond the scope of this guide. Also see http://getbootstrap.com/customize/ for details about customizing stylesheets to match your component use.

    Themes

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

    Browser support

    We aim to support all browsers supported by both React and Bootstrap.