![]() |
MUI or Material-UI is a UI library providing predefined robust and customisable components for React for easier web development. The MUI design is based on top of Material Design by Google. In this article, we will discuss the React MUI MenuList API. The menu displays a list of choices of action that we can perform on the site. MenuItem is each item displayed in the Menu. The API provides a lot of functionality and we will learn to implement them. Import MenuItem API import MenuItem from '@mui/material/MenuItem'; // or import { MenuItem } 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.
CSS Rules:
Syntax: Create a Menu with MenuItem as follows: <MenuList> <MenuItem>HTML</MenuItem> ... </MenuList> 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:
Step 4: Run the project as follows: npm start Example 1: In the following example, we have a Menu with MenuItems. App.js
Output: ![]()
Example 2: In the following example, we have made the menu colorful using sx field. App.js
Output: ![]()
Reference: https://mui.com/material-ui/api/menu-item/ |
Reffered: https://www.geeksforgeeks.org
ReactJS |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |