CSS
Bootstrap
How To Install Bootstrap In React App?
In this article we will cover on how to implement react install bootstrap example. i would like to show you how to install bootstrap in react js. you will learn how to use bootstrap in react native. let’s discuss about how to install bootstrap 4 in react native. You just need to some step to done how to include bootstrap in react.
- 4.5/5.0
- Last updated 08 September, 2022
- By Admin
In this post, i will show you two way to install bootstrap in react application.
1) we will use npm bootstrap library so you can easily use all the classes of bootstrap 4 in your react js app.
2) we will use react-bootstrap they provide library for bootstrap javascript. so you can easily import bootstrap buttons, alert, navbar, model and work on it.
Now let's see both way one by one and you can use any one way that you require
Preview:
1) Install Bootstrap 4
Now here, we have to install bootstrap using npm command. so let's run bellow command to install bootstrap in react
npm install --save bootstrap
After 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( , document.getElementById('root') ); serviceWorker.unregister();
Now we are ready to use bootstrap class. so you can use it as like bellow i used.
src/App.js
import React from 'react'; import logo from './logo.svg'; import './App.css'; function App() { return ( ); } export default App;How to Install Bootstrap in React App - codewale.com
This is success alert.
This is primary alert.
This is danger alert.
2) Install react-bootstrap
Now here, we have to install bootstrap using npm react-bootstrap command. so let's run bellow command to install bootstrap in react
npm install react-bootstrap bootstrap
After 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( , document.getElementById('root') ); serviceWorker.unregister();
Now we are ready to use bootstrap class with import component. so you can use it as like bellow i used.
src/App.js
import React from 'react'; import logo from './logo.svg'; import './App.css'; import { Button, Alert } from 'react-bootstrap'; function App() { return ( ); } export default App;This is a success alert—check it out!
Now you can use anyone way.
I hope it can help you...