When implementing native HTML tables in React applications, the structure mirrors standard HTML markup, adapted to JSX syntax. A complete table typically consists of three main sections:
<thead>- Contains header rows with column titles<tbody>- Holds the main data content rows<tfoot>- Optinoal footer section for summary information
Each row is defined using <tr> elements, while individual cells use either <th> for headers or <td> for data cells.
Basic Table Structture Example
<table>
<thead>
<tr>
<th>Header Column 1</th>
<th>Header Column 2</th>
<th>Header Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
<td>Row 1 Data 3</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
<td>Row 2 Data 3</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colSpan={3}>Footer Information</td>
</tr>
</tfoot>
</table>
React Component Implementation
In React, attributes follow camelCase conventions: className instead of class, and colSpan instead of colspan.
import React from 'react';
function SalesDataTable() {
return (
<table className="data-table">
<thead>
<tr>
<th>Date</th>
<th>Revenue</th>
<th>Profit Margin</th>
</tr>
</thead>
<tbody>
<tr>
<td>2025-04-01</td>
<td>$1,000</td>
<td>20%</td>
</tr>
<tr>
<td>2025-04-02</td>
<td>$1,200</td>
<td>20.8%</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colSpan={3}>Source: Internal Sales Database</td>
</tr>
</tfoot>
</table>
);
}
export default SalesDataTable;
This component can be enhanced with CSS styling or integrated with UI libraries like Tailwind CSS for improved visual presentation. For dynamic data rendering, the table structure can be mapped from arrays of objects using JavaScript's map function within the JSX.