Material-UI Flashcards
What is material UI?
It is just a React UI library, which provides pre-baked, react components.
How MUI provides different variants of a single component?
By providing different “props”/properties, we can use different variants of same component.
How a new person can read about different variants of any component?
It provides we formed documents, which provides information about each component APIs and different variants.
How to install MUI in react?
It is done by installing three important libraries:
- mui/material
- emotion/react
- emotion/styled
What is emotion library?
Emotion is an styling engine, which helps in writing CSS with javascript.
Which CSS library is used by MUI?
emotion
How to import any component from MUI?
Using following import statement:
import Button from ‘@mui/material/Button’
How can we change the variant of the button?
It can be changed by using property as “variant” and the different value of the property e.g.
My Button
Can we disable a button by using property?
Yes, we can use “disabled” property to make any button as disabled.
How to add a on-click event on a button?
This is done by using “onClick={}” property to the button. Any function passed to this function, will get executed once a user click over the button.
Does Icons included in MUI package?
No, we need to install it separately.
How can we install the icons requirements?
Using MUI’s “icons-material” package.
e.g. npm install @mui/icons-material
What is the purpose of “export default”?
This is required when we want to export only a single value from a file which can be:
- Class
- Function
- Object
What is a component in React?
It is nothing but a “function” which is exporting a react element.
How to consume a “component’ inside the “app.js’ file?
Import the react component and then call same just like a html tag.
e.g.
import NavBar from ‘./components/nav-bar/navBar.js’
<div>
</div>