Table of contents
1.
Introduction
2.
How to Create Table in React js
2.1.
Creating a React App
2.2.
Move to the Project Directory
2.3.
Creating a Static Table in React js
2.4.
 Creating a dynamic table in react js
3.
Why is Table in ReactJS Important?
4.
DataTable in ReactJS
4.1.
Configuration
4.2.
Example
5.
Advantages of Table in ReactJS
6.
Frequently Asked Questions
6.1.
How do you create a table in react JS?
6.2.
What is the use of table in react?
6.3.
How do I display a table in ReactJS?
6.4.
Should I use tables in react?
6.5.
How do I use HTML tables in react JS?
7.
Conclusion
Last Updated: Aug 13, 2025
Easy

Table in React js

Author Akshit Mehra
1 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

A table is an arrangement that divides information into rows and columns. Its purpose is to store and display structured data. React-Table is used for this purpose in react. React-table is an open-source library that allows you to create tables in the React framework. It is a lightweight, fast, and fully customizable React Datagrid that can be expanded (JSX, templates, state, styles, and callbacks). Many well-known tech companies, including Google, Apple, and Microsoft, are used. This tutorial will teach us how to create table in react js applications, a standard functionality in the web world.

If you want to learn how to create dynamic table in React js, this tutorial will help you. We here assume that you have a basic understanding of React and are familiar with its Functional and Class Components in React.

How to Create Table in React js

Below are the step by step commands on how to create table in react js.

Creating a React App

Creating a React App

The project name is React-table-app. You can choose any name of your choice. You can skip the first step to create a customised and dynamic table in an existing application.

Move to the Project Directory

We must run the command below to navigate to the project directory in this step. Use the cd command and the project name to get to the project directory.

Move to the Project Directory

If you import your project into any code editors after step 2, your project structure will look like this:

code editors

Creating a Static Table in React js

The app component is the React JS application's default component. So, we'll here see how we can use the App component to create a static table in React JS. Following that, we'll look at making a customised and dynamic table. Below are the changes made in the App.js file:

import logo from "./logo.svg";
import "./App.css";

function App() {
  return (
    <div className="App">
      <h1>Students Table</h1>
      <table>
        <thead>
          <tr>
            <th>Name</th>
            <th>Age</th>
            <th>Gender</th>
            <th>Roll Number</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>Akram</td>
            <td>21</td>
            <td>Male</td>
            <td>2019MEB1235</td>
          </tr>
          <tr>
            <td>Jason</td>
            <td>22</td>
            <td>Male</td>
            <td>2018CSB1234</td>
          </tr>
          <tr>
            <td>Dave</td>
            <td>20</td>
            <td>Female</td>
            <td>2019eeb1242</td>
          </tr>
          <tr>
            <td>Tom</td>
            <td>20</td>
            <td>Male</td>
            <td>2019mmb1235</td>
          </tr>
          <tr>
            <td>Stark</td>
            <td>20</td>
            <td>Male</td>
            <td>2019meb1290</td>
          </tr>
        </tbody>
      </table>
    </div>
  );
}

export default App;
You can also try this code with Online Javascript Compiler
Run Code

 

There is nothing advanced in the above code; we used basic HTML tags. The changes we need to make in the App.css file to apply the style to our Table are also listed below:

table {
  width: 800px;
  height: 200px;
  border-collapse: collapse;
}

th {
  border-bottom: 1px solid black;
  border: 2px solid black;
}

td {
  text-align: center;
  border: 2px solid black;
}

 

After making all of the changes, the command to run our app is as follows:

Creating a Static Table in React js

When you run the following command, it will host your application on port 3000, and you will see the output shown below:

Name Age Gender Roll Number
Akram 21 Male 2019MEB1235
Jason 22 Male 2018CSB1234
Dave 20 Female 2019eeb1242
Tom 20 Male 2019mmb1235
Stark 20 Male 2019meb1290

 Creating a dynamic table in react js

The majority of the time, your requirement in the application is to populate the dynamic data in the React table. Your table in react js code should be dynamic to generate a dynamic and customised Table that occupies the data in the array. Therefore, it becomes important to learn how to create dynamic table in react js.

Simply put, we define an array and populate it with data. In real-world applications, however, our array comes from the backend and contains the data that you want to display. Assume we have an array like the one below and want to display the array data in our Table.

const data = [
  { name: "Akram", age: 21, gender: "Male", Roll_Number: "2019meb1235" },
  { name: "Michael", age: 22, gender: "Female", Roll_Number: "2019csb1225" },
  { name: "Manisha", age: 22, gender: "Female", Roll_Number: "2018meb1236" },
  { name: "Tanishq", age: 21, gender: "Male", Roll_Number: "2018eeb1190" },
  { name: "Stark", age: 19, gender: "Female", Roll_Number: "2019csb1212" }
]
You can also try this code with Online Javascript Compiler
Run Code

 

Instead of manually looping through the entire array, we can use the array's inbuilt method, array.map (). The callback function allows us to iterate over the array and modify its elements using array.map(). This callback function will then be called on all the array elements. In this case, we will return the table row at the end of each iteration. The complete App.js file code is provided below.

import logo from "./logo.svg";
import "./App.css";

const data = [
  {
    name: "Akram",
    age: 21,
    gender: "Male",
    Roll_Number: "2019meb1235",
  },
  {
    name: "Michael",
    age: 22,
    gender: "FeMale",
    Roll_Number: "2019csb1225",
  },
  { name: "Manisha", age: 22, gender: "Female", Roll_Number: "2018meb1236" },
  { name: "Tanishq", age: 21, gender: "Male", Roll_Number: "2018eeb1190" },
  { name: "Stark", age: 19, gender: "Female", Roll_Number: "2019csb1212" },
];

function App() {
  return (
    <div className="App">
      <h1>Students Table</h1>
      <table>
        <thead>
          <tr>
            <th>Name</th>
            <th>Age</th>
            <th>Gender</th>
            <th>Roll Number</th>
          </tr>
        </thead>
        <tbody>
          {data.map((value, key) => {
            return (
              <tr key={key}>
                <td>{value.name}</td>
                <td>{value.age}</td>
                <td>{value.gender}</td>
                <td>{value.Roll_Number}</td>
              </tr>
            );
          })}
        </tbody>
      </table>
    </div>
  );
}

export default App;

 

When you run the code with npm start, you should see the following output in your browser:

When you run the following command, it will host your application on port 3000, and you will see the output shown below:

Name Age Gender Roll Number
Akram 21 Male 2019meb1235
Micheal 22 Female 2019CSB1225
Manisha 22 Female 2018meb1236
Tanishq 21 Male 2018eeb1190
Stark 19 Female 2019csb1212

    

A               Above,   we saw how to create dynamic table in react js. We will next proceed towards some FAQ’s.

Click on    Click on the following link to read further: Hooks in React JS

Why is Table in ReactJS Important?

The table in ReactJS is important for creating tables in the React framework. It is an open-source library. It is utilized to hold and present structured data. Built specifically for React, the react-table is a lightweight, quick, fully customisable (JSX, templates, state, styles, callbacks), and expandable Datagrid. Using optional props and callbacks, it is entirely controllable. Numerous well-known IT companies, including Google, Apple, and Microsoft, use it.

Our React Js Course covers these essential topics in depth, helping you to learn more about React Js.

DataTable in ReactJS

A potent Javascript framework called DataTables allows you to enhance HTML tables with cutting-edge interactivity features. This ReactJS component is a simple Table widget designed to take the place of your HTML Tables. This is often helpful, especially if your software application needs to perform additional tasks like pagination, sorting, searching, etc., in addition to simply displaying data from a database. All those features are built into DataTables.

Configuration

For the configuration of the DataTable in React, some imports are needed. The major imports include React, ReactDom, and JqxDataTable.

After importing all the needed functionalities, we need to create the component class.  

Configuration

The last step is rendering the component in the HTML element. 

Example

Let us see an example to see how to create a DataTable. 

import React from 'react';  //importing the required functionalities 
import ReactDOM from 'react-dom';

import JqxDataTable from 'jqwidgets-react/react_jqxdatatable.js';

class App extends React.Component {
 render () {
   let source =
   {
       localdata: generatedata(50),
       datatype: "list",  //generation of the DataTable 
       datafields:
       [
           { name: 'employeename', type: 'string' },
           { name: 'employeeid', type: 'number' },
           { name: 'salary', type: 'number' },
       ]
   };
   let dataAdapter = new $.jqx.dataAdapter(this.source);

   let columns = 
   [
       { text: 'Name', dataField: 'employeename', width: 200 },
       { text: 'ID', dataField: 'employeeid', width: 200 },
       { text: 'Income', dataField: 'salary', width: 180 },
   ];
   return (
       <JqxDataTable 
           source={dataAdapter} sortable={true}
           pageable={true} columns={columns}
        />
   )
 }
}

ReactDOM.render(<App />, document.getElementById('app')); //rendering the component to the desired HTML element

Advantages of Table in ReactJS

Some advantages of tables in ReactJS are the following:

  • React Table leverages hooks to aid in the construction of tables, providing you with total flexibility over how you want the UI to look and work.
  • These hooks are quick, quick, flexible, and entirely adaptable.
  • Both the client and server sides support pagination.
  • Data can be sorted in ReactTable in both ascending and descending order.

Also, See, Dropdown in React JS
Check out Advantages of React JS here.

Frequently Asked Questions

How do you create a table in react JS?

To create a react-table, we must utilize package management (Yarn or npm). Then execute the following command to import the library into our React app: import { useTable } from 'react-table';  We must specify the table's columns and data once it has been created.

What is the use of table in react?

It's easy to set up, edit, and expand React tables. In the React framework, it is used to create tables. We can modify or extend any logical step, stage, or process internally with React-own table's plugin system.

How do I display a table in ReactJS?

Follow the instructions to display a table in react JS. Create a component called DisplayFormDataInTable. To add data, create a form component. To display data, create a table component. DisplayFormDataInTable Component should be rendered. Launch the app to see the form's data in a table.

Should I use tables in react?

Yes, you should use tables in react. Use React table if you require a straightforward table with less data and fundamental capabilities like sorting, global filtering, column filtering, and pagination. Or if you desire total control over the styling and Interface of the table.

How do I use HTML tables in react JS?

Using the map function, you may use an HTML table in react JS. The map() method iterates through each element of the array, converting each one into a row of a table. For this, a table tag needs to be created.

Conclusion

So, we end our above blog here. Above, we have extensively discussed Table in React js. We saw how to create table in react js in both static and dynamic cases. We hope that this blog has helped you enhance your knowledge regarding React tables and how to create table in react js. We also saw, how to create dynamic table in React Js.

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available, interview puzzles, take a look at the interview experiences, and interview bundle for placement preparations.

Recommended Readings:

Live masterclass