Join WhatsApp ChannelJoin Now

How to Install Bootstrap in React

In this article, we will show you Install Bootstrap in React . i would like to show you how to install bootstrap in react js. you will learn how to Install bootstrap in react.

In this article, we will show you Install Bootstrap in React . i would like to show you how to install bootstrap in react js. you will learn how to Install bootstrap in react.

In this article, we show you two way to install bootstrap in react application.

Now let’s see both way one by one and you can use any one way that you require

First Example

1 Step:- Install Bootstrap 4

install bootstrap using npm command

npm install --save bootstrap

successfully install bootstrap, we need to import bootstrap css in src/index.js file as like bellow.

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

src/index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import 'bootstrap/dist/css/bootstrap.css';
   
ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
serviceWorker.unregister();

Second Example

1 Step:- Install react-bootstrap

install bootstrap using npm react-bootstrap command.

npm install react-bootstrap bootstrap

successfully install bootstrap, we need to import bootstrap css in src/index.js file as like bellow.

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

src/index.js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import 'bootstrap/dist/css/bootstrap.css';
   
ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
serviceWorker.unregister();

Recommended Posts