React – How to add Bootstrap in a project

By | 18/11/2020

In this post, we will see how to add Bootstrap in the project created in the post: React – Fetch data in Class component.

First of all, we install the last version of Bootstrap using the command npm install –save bootstrap
Then, we delete the code used to define the table’s style in the file in index.css:


body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #333;

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',

Finally, we modify the files HTMLUserList.js and App.js, in order to add Bootstrap at the application


import React from 'react'

const HTMLUserList = ({users}) => {
    return (
            <div style = {{width: "100%"}}>
                <table class="table">
                            <th scope="col">UserName</th>
                            <th scope="col">Password</th>
                            <th >Created At</th>
                    { =>
                        <tr key={}>

export default HTMLUserList;


import React from 'react';
import './App.css';
import ListUsers from './components/GetListUsers';
import 'bootstrap/dist/css/bootstrap.css';

function App() {
  return (
    <div className="App">

export default App;

Now, if we run the application this will be the result:

Leave a Reply

Your email address will not be published. Required fields are marked *