Friday, September 5, 2025
HomeLanguagesReact MUI TableCell API

React MUI TableCell API

MUI or Material-UI is a UI library providing predefined robust and customizable components for React for easier web development. The MUI design is based on top of Material Design by Google. 

In this article, we are going to discuss the React MUI TableCell API. TableCell is used to place the content of the tables that is the data. A table is a component used to display a collection of data. The API provides a lot of functionality and we will learn to implement them.

Import TableCell API

import TableCell from '@mui/material/TableCell';
// or
import { TableCell } from '@mui/material';

Props List: Here is the list of different props used with this component. We can access them and modify them according to our needs.

  • children (node): It is a component similar to the table row.
  • classes (Object): Override the existing styles or add new styles to the component.
  • component (elementType): It is the component used for the root node. It can be either an HTML string or a component.
  • sx (Array<func / object/bool> / func / object): The system prop allows defining system overrides as well as additional CSS styles
  • align (centre, inherit, justify, left, right): The default value is inherited and it sets the direction of the content of the cell.
  • padding (checkbox, none, normal): It sets the padding of the cell.
  • scope (string): It sets the scope attributes.
  • size (small, medium): It specifies the size of the cell. 
  • sortDirection (asc, desc, false): Set the sort direction
  • variant (body, footer, header): It specifies the cell type.

Syntax: Create a TableCell component inside the table as follows:

<Table aria-label="simple table">
    <TableBody>
        <TableRow>
            <TableCell>Sl. No.</TableCell>
            <TableCell align="right">Name</TableCell>
            <TableCell align="center">Age</TableCell>
        </TableRow>
    </TableBody>
</Table>

Installing and Creating React app, and adding the MUI dependencies.

Step 1: Create a react project using the following command.

npx create-react-app gfg_tutorial

Step 2: Get into the project directory

cd gfg_tutorial

Step 3: Install the MUI dependencies as follows:

npm install @mui/material @emotion/react @emotion/styled @mui/lab

Step 4: Run the project as follows:

npm start

Example 1: In the following example, we have a table with cells. The content of the cells has different alignments.

App.js

 
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11861 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6699 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS