React MUI is a UI library that provides fully-loaded components, bringing our own design system to our production-ready components. MUI is a user interface library that provides predefined and customizable React components for faster and easy web development, these Material-UI components are based on top of Material Design by Google.
One of the main advantages of using MUI is that it allows developers to quickly and easily create professional-looking interfaces without having to spend a lot of time on design. The library includes a wide range of components, including buttons, forms, layout grids, and more, all of which are designed to be fully customizable and adaptable to different use cases.
MUI provides various types of components:
Component Type | Description |
---|
Input | The Input components in MUI is a standard input field that can be used to gather information from the user. |
Data display | These components provide a convenient and consistent way to display data and information in your Material-UI-based applications. |
Feedback | It refers to a set of components that provide ways to communicate the outcome of an action to the user. |
Surface | It refers to a type of component that provides a container for other UI elements. |
Navigation | It refers to a type of component that is used to create navigation interfaces for an application. |
Layout | It refers to a type of component that is used to organize the structure and layout of an application’s UI. |
Utils | Utils refer to a set of utility functions and components that enhance the functionality and user experience of the MUI library. |
Data grid | A data grid, also known as a data table, is a UI component for displaying large amounts of structured data in a tabular format. It typically includes columns for different data fields, rows for individual data records, and features for sorting, filtering, pagination, selection, and more. |
Labs | It is a collection of experimental components and tools that are developed and maintained by the Material-UI team. It provides a platform for exploring new and innovative ideas for user interface components. |
Syntax: Button component syntax:
import { Button } from '@mui/material';
function App() {
return (
<Button variant="contained" color="primary">
Click Me
</Button>
);
}
export default App;
Creating React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. folder name, move to it using the following command:
cd foldername
Step 3: After creating the ReactJS application, Install the required module using the following command:
npm install @mui/material
npm install @emotion/react
npm install @emotion/styled
Project Structure: It will look like the following.
Step to Run Application: Open the terminal and type the following command.
npm start
Example 1: In this example, we will make a card that contains textfield & button components.
Javascript
import * as React from "react" ;
import {
Button,
Card,
CardMedia,
CardActions,
CardContent,
TextField,
} from "@mui/material" ;
export default function Demo() {
return (
<div>
<Card raised={ true } sx={{ maxWidth: 400 }}>
<CardMedia
component= "img"
height= "200"
image=
alt= "GFG Logo"
/>
<CardContent sx={{ bgcolor: "#E8E8E8" }}>
<h3>Top interview Questions</h3>
<h4 style={{ color: "green" }}>
As the placement season is back so are we to
help you ace the interview. We have selected
some most commonly asked and must do practice
problems for you. You can also take part in
our mock placement contests which will help
you learn different topics and practice at
the same time, simulating the feeling of a
real placement test environment.
</h4>
</CardContent>
<CardActions>
<TextField
id= "outlined-basic"
label= "Referral code"
variant= "outlined"
/>
<Button variant= "contained" color= "primary" >
Share
</Button>
<Button variant= "contained" color= "success" >
Enroll
</Button>
</CardActions>
</Card>
</div>
);
}
|
Output:
Example 2: In this example, we will create a drawer that opens above all the content of the page like a modal with a backdrop. We will use components like Drawers & Buttons.
Javascript
import * as React from "react" ;
import Drawer from "@mui/material/Drawer" ;
import Button from "@mui/material/Button" ;
import MenuItem from "@mui/material/MenuItem" ;
export default function App() {
const [open, setOpen] = React.useState( false );
function handleOpen() {
setOpen(!open);
}
function handleClose() {
setOpen( false );
}
return (
<>
<Button onClick={handleOpen}
variant= "outlined"
color= "success" >
Open Drawer
</Button>
<Drawer anchor={ "left" }
open={open}
onClose={handleClose}>
<MenuItem>
<h1>GeeksForGeeks</h1>
</MenuItem>
<MenuItem>My profile</MenuItem>
<MenuItem>Saved articles</MenuItem>
<MenuItem>Saved Videos</MenuItem>
<MenuItem>Courses</MenuItem>
<MenuItem>Logout</MenuItem>
</Drawer>
</>
);
}
|
Output:
Reference: https://mui.com/components/
Similar Reads
React Components
In React, React components are independent, reusable building blocks in a React application that define what gets displayed on the UI. They accept inputs called props and return React elements describing the UI. In this article, we will explore the basics of React components, props, state, and rende
4 min read
React MUI Input Components
React MUI Input Components are various types of Input Components along with enhanced styling and functionalities provided by the React Material-UI (MUI). The MUI Input components refer, to a standard input field that can be used to gather information from the user. These are various types of input c
3 min read
React MUI Layout Components
React Material-UI (MUI) is a popular library that provides a set of reusable components for building user interfaces in React applications. These components are based on Material Design, a design system developed by Google that provides guidelines for creating visually appealing, user-friendly inter
2 min read
ReactJS Pure Components
ReactJS Pure Components are similar to regular class components but with a key optimization. They skip re-renders when the props and state remain the same. While class components are still supported in React, it's generally recommended to use functional components with hooks in new code for better p
4 min read
React MUI Surface Components
React Material-UI (MUI) is a popular library that provides a set of reusable components for building user interfaces in React applications. These components are based on Material Design, a design system developed by Google that provides guidelines for creating visually appealing, user-friendly inter
2 min read
React MUI Avatar Component
React MUI is a UI library providing predefined robust and customizable components for React for easier web development. Material-UI is a user interface library that provides predefined and customizable React components for faster and easy web development, these Material-UI components are based on to
3 min read
React MUI Feedback Components
React Material-UI (MUI) is a popular library that provides a set of reusable components for building user interfaces in React applications. These components are based on Material Design, a design system developed by Google that provides guidelines for creating visually appealing, user-friendly inter
2 min read
React MUI Unstyled Components
In React, Material-UI is a popular library for creating user interfaces that follow Google's Material Design guidelines. The library provides a set of styled components that you can use in your React application, such as Buttons, Input, and Paper. Unstyled components refer to components that are not
3 min read
React MUI Navigation Components
React Material-UI (MUI) is a popular library that provides a set of reusable components for building user interfaces in React applications. These components are based on Material Design, a design system developed by Google that provides guidelines for creating visually appealing, user-friendly inter
3 min read
React styled-components Module
React Styled-component Module allows us to write CSS within JavaScript in a very modular and reusable way in React. Instead of having one global CSS file for a React project, we can use styled-component to enhance the developer experience. It also removes the mapping between components and styles â
2 min read