Skip to content
Related Articles
Open in App
Not now

Related Articles

React MUI TableCell API

Improve Article
Save Article
Like Article
  • Last Updated : 13 Jul, 2022
Improve Article
Save Article
Like Article

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">
            <TableCell>Sl. No.</TableCell>
            <TableCell align="right">Name</TableCell>
            <TableCell align="center">Age</TableCell>

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.





Example 2: In the following example, we have link cells with different background colors.






My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!