Thursday, November 28, 2024
Google search engine
HomeLanguagesReact MUI TableRow API

React MUI TableRow API

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 TableRow API. The Tables are used to display a collection of data. The TableRow in a row in the table that appears as a horizontal strip. The API provides a lot of functionality and we are going to learn to implement them.

Import TableRow API:

import TableRow from '@mui/material/TableRow';
// or
import { TableRow } 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: It is a component similar to the table row.
  • classes: This overrides the existing styles or adds new styles to the component.
  • sx: The system prop allows defining system overrides as well as additional CSS styles. 
  • component: The component is used as the root node.
  • hover: If true, the row will display a shade on hover.
  • selected: If true, the row will display a shade on selected.

Syntax: Create the TableRow component as follows:

<TableRow hover key={row.name}>
    <TableCell component="th" scope="row">
        {row.index}
    </TableCell>
    <TableCell>{row.tutorial}</TableCell>
    <TableCell>
        <a href={row.link} target="_blank">
            {row.link}
        </a>
    </TableCell>
</TableRow>

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 TableRow which shows a shade on hover.

App.js

 
RELATED ARTICLES

Most Popular

Recent Comments