Important Update
The Guide Feature will be discontinued after December 15th, 2023. Until then, you can continue to access and refer to the existing guides.
Author avatar

Gaurav Singhal

How to Import Components from React Bootstrap

Gaurav Singhal

  • May 18, 2020
  • 6 Min read
  • May 18, 2020
  • 6 Min read
Web Development
Front End Web Development
Client-side Framework


React Bootstrap is one of the widely used libraries in React, and its various components are used in React apps to make them mobile-friendly. It has tons of components that give apps the various details of layout, form controls, information indicators, and navigational components.

In this guide, you are going to learn how to add React Bootstrap into a React app by importing and using the React Bootstrap components in your React components.

Adding React Bootstrap into a React App

Install the React Bootstrap library by using the below npm command.

1npm install react-bootstrap bootstrap

After installing the above two libraries, the next step is to add bootstrap CSS file into either index.js or app.js like this:

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

Alternatively, if you are using SASS in your app, you can add it as shown below.


1@import "~bootstrap/scss/bootstrap";


1import './App.scss';

Now you are good to go and can proceed further with React Bootstrap by importing various components into your React app.

Importing Components from React Bootstrap

Now that you have installed the bootstrap library and configured the CSS file into your app, it’s time to import the components from react-bootstrap.

The basic syntax for importing anything from react-bootstrap looks like this:

1import { COMPONENT_NAME } from 'react-bootstrap';


1import COMPONENT_NAME from 'react-bootstrap/COMPONENT_NAME';

It is the basic syntax that’s used to import the specific components from the library, but you can still import it using other ways that you will learn in the next section of this guide.

Import Components from the React Bootstrap Library

Importing Single Components

You can import any single component from react-bootstrap as explained below.

1import React, { Component } from "react";
2import { Image } from "react-bootstrap";
4class SingleComponent extends Component {
5  render() {
6    return (
7      <div>
8        <Image
9          src=""
10          thumbnail
11        />
12      </div>
13    );
14  }
17export default SingleComponent;

In the above example, to import the single component called Image from the react-bootstrap library, the command used is:

1import { Image } from "react-bootstrap";

Inside the render() function, the <Image/> component is used along with various properties like href and another supporting property called thumbnail.

This is how you can import any single component from React Bootstrap:

  • Import Single Components Individually

You can import and use any React Bootstrap components individually from react-bootstrap rather than importing them from the complete library as shown below.

1import React, { Component } from "react";
2import Breadcrumb from "react-bootstrap/Breadcrumb";
4class SingleIndividualComp extends Component {
5  render() {
6    return (
7      <Breadcrumb>
8        <Breadcrumb.Item href="#">Home</Breadcrumb.Item>
9        <Breadcrumb.Item href="#">Profile</Breadcrumb.Item>
10        <Breadcrumb.Item active>Test123</Breadcrumb.Item>
11      </Breadcrumb>
12    );
13  }
16export default SingleIndividualComp;

As shown in the above example, Breadcrumb individually imported by using this command:

1import Breadcrumb from "react-bootstrap/Breadcrumb";

Pulling the specific component from the library rather than picking up the whole package improves the performance while fetching and rendering the particular component.

  • Use React Bootstrap Default Syntax

The default syntax is a way to use React Bootstrap dynamically without naming the specific components, as done previously.

1import React, { Component } from "react";
2import * as ReactBootstrap from "react-bootstrap";
4class DynamicImport extends Component {
5  render() {
6    return (
7      <ReactBootstrap.Button bsStyle="success" bsSize="small">
8        Something
9      </ReactBootstrap.Button>
10    );
11  }
14export default DynamicImport;

The above example does not import any components by name but used a dynamic import format to fetch a specific component when needed, as shown below.

1import * as ReactBootstrap from "react-bootstrap";

When you need any components while developing the UI, you have to use prefix ReactBoootstrap.comp_name followed by the specific component name, which makes it easier to use.

Importing Multiple Components

So far in this guide, you have learned how to import a single specific component, but you can import multiple components from the single import statement as well.

Below is a simple example that shows how to import multiple components from react-bootstrap from a single import statement.

1import React, { Component } from "react";
2import { Form, Col, Button } from "react-bootstrap";
4class MultipleImport extends Component {
5  render() {
6    return (
7      <Form>
8        <Form.Row>
9          <Col>
10            <Form.Control placeholder="First name..." />
11          </Col>
12          <Col>
13            <Form.Control placeholder="Last name..." />
14          </Col>
15          <Col>
16            <Button>Submit</Button>
17          </Col>
18        </Form.Row>
19      </Form>
20    );
21  }
24export default MultipleImport;

In the above example, three components, Form, Col, and Button, are imported from the single import statement.

1import { Form, Col, Button } from "react-bootstrap";

It’s pretty handy sometimes because you don’t need to have multiple import statements that import a single component from the same library concurrently.


In this guide, you have learned the various methods for importing components, like importing single components, individual components, dynamic components, and multiple components using a single import statement.

You can choose any of these methods, but when it comes to the performance, the multiple components import statement or individual component import are way better than the others. I hope this guide helps you to play around importing various components. That was it from this guide; be safe, and keep coding.