DEV Community

Cover image for Why Material UI ?
RRARI504
RRARI504

Posted on

Why Material UI ?

What is Material UI?

Imagine a well-designed component library that is based off of Google's 'Material Design', offers a set of premade React components that are customizable and theme based and easy to use. That is what Material UI offers.

Material UI, other wise known as MUI, is a popular open sourced React UI framework. It helps accelerate development by giving developers a library of react components that are easily customizable and that implement Google's Material Design guidelines. So, instead of having to build out UI components from scratch like buttons or forms, Material UI gives them to you in easy to read blocks of code that can be added to your personal project.

Why is MUI popular?

There are many reasons why MUI is such a popular framework; here are a few reasons; Material UI uses Google's Material design system which helps teams bring to life seamless user interfaces for Android, IOS and the web. Developed in 2014, the goal was to help let developers build intuitive, consistent, cross-platform UI's.

'The purpose of developing Material Design was to create a novel visual language, synthesizing the classic principles of good design with the innovation and possibility of technology and science'(2).

This alone saves a developer time since they wouldn't have to design components themselves for project. They could use premade components that are up to par with todays standards.

Another reason why MUI is popular is because of how it is integrated with React. It is basically built for React applications so it coincides with parts of Reacts already made architecture like state and props making development even easier.

Material UI also is know for having really good and easy to read documentation. Part of the reason for this is because MUI has a large active community of devs behind it. So, help and sources with how MUI functions and how to use it are readily available through resources like Stack Overflow, etc.

What is React?

Lets briefly explain the foundation of which Material UI is build on, React.

'React is a JavaScript library (maintained by Facebook/Meta) for building user interfaces, especially single-page applications. One of its core ideas is building UIs by composing “components” — reusable pieces of UI logic and markup' (5).

A react component is basically a JavaScript function, or class, that returns some UI or "JSX" and accepts “props” (inputs) and manages “state” (internal data) and lifecycle. So, when using Material UI you would be using the 'React component model' and it would go something like this; you import a component like a button, you use it in your JSX like <Button variant="contained">Click me</Button>, you can then pass props and style it via theme/customization. If you were making a React application and wanted to use a button from Material UI, this is what the code would look like...

import * as React from 'react';
import Stack from '@mui/material/Stack';
import Button from '@mui/material/Button';

export default function BasicButtons() {
  return (
    <Stack spacing={2} direction="row">
      <Button variant="text">Text</Button>
      <Button variant="contained">Contained</Button>
      <Button variant="outlined">Outlined</Button>
    </Stack>
  );
}
Enter fullscreen mode Exit fullscreen mode

This component displays three Material UI buttons side by side, each showing a different visual variant to demonstrate how MUI styling works.

This one component imports the React library, which is required to create and use components in JSX. It imports the Stack and Button components from Material UI; the button component supports different variants like “text,” “contained,” and “outlined.” Lastly, it defines and exports a React functional component named 'BasicButtons', so it can be imported and used in other files. BasicButtons creates a horizontal row layout (direction="row") with spacing of 2. Inside the stack are three buttons, each with a different style as seen above.

Conclusion

In a time where we want things as optimized as possible, MUI is a powerful, modern day tool that can help developers streamline their projects with speed and a consistent polished design. MUI is a go to for building responsive web interfaces, specifically for React applications, and shows that quality doesn't come at the cost of productivity.

Sources

  1. https://mui.com/material-ui/
  2. https://m2.material.io/design/introduction#principles
  3. https://en.wikipedia.org/wiki/Material_Design
  4. https://how.dev/answers/what-is-material-ui-in-react
  5. https://react.dev/learn/your-first-component
  6. https://mui.com/system/getting-started/
  7. https://www.animaapp.com/blog/industry/what-is-material-design-and-why-should-you-use-it/
  8. https://blog.42mate.com/chakra-ui-vs-material-ui-vs-tailwindcss-for-reactjs/
  9. https://mui.com/material-ui/react-button/

Top comments (0)