Material UI — Simple Interview Q&A

1. What is Material UI?

MUI is a React UI library that provides ready‑made components like buttons, inputs, cards, etc.

import Button from "@mui/material/Button";

export default function App() {
 return <Button variant="contained">Click Me</Button>;
}

2. Why do we use Material UI?

To create UI faster, look professional, responsive, and avoid writing long CSS.

<TextField label="Email" variant="outlined" />

3. How to install MUI?

npm install @mui/material @emotion/react @emotion/styled

4. What is the Button component?

MUI gives different button styles using variant and color.

<Button variant="contained">Submit</Button>
<Button variant="outlined" color="secondary">Cancel</Button>
<Button variant="text" color="error">Delete</Button>

5. What is the sx prop?

It allows quick inline styling inside MUI components.

<Button sx={{ backgroundColor: "green", padding: "10px" }}>Save</Button>

6. What is Box?

import Box from "@mui/material/Box";

A layout container used for spacing, padding, margin, flex, etc.

<Box sx={{ p: 2, backgroundColor: "#eee" }}>Box Container</Box>

7. What is Grid?

Used to make responsive layouts using a 12‑column system.

import Grid from "@mui/material/Grid";

<Grid container spacing={2}>
 <Grid item xs={6}>Left</Grid>
 <Grid item xs={6}>Right</Grid>
</Grid>

8. What is TextField?

An input component with built‑in design and label.

<TextField label="Username" fullWidth />

9. What is ThemeProvider?

Used to set global colors, fonts, and theme settings for the whole app.

const theme = createTheme({ palette: { primary: { main: "#1976d2" }}});

<ThemeProvider theme={theme}>
 <Button>Click</Button>
</ThemeProvider>

10. What is AppBar?

Used to create top navigation bars.

<AppBar position="static" >
 <Toolbar>My App</Toolbar>
</AppBar>

11. How to use MUI Icons?

import HomeIcon from "@mui/icons-material/Home";

<HomeIcon />

12. What is Card?

CardContent is a Material UI component that provides padding, spacing, and layout for the inside section of a Card.

<Card>
 <CardContent>Title</CardContent>
</Card>

13. How to customize MUI Button using styled()?

You can create custom styled components using MUI’s styled() API.

import { styled } from "@mui/material/styles"; import Button from "@mui/material/Button";

const MyButton = styled(Button)({
backgroundColor: "#0077ff",
padding: "10px 25px",
borderRadius: "10px",
});

<MyButton>Custom Button</MyButton>

14. How to create a responsive layout using MUI Grid?

Grid can change its size based on breakpoints.

<Grid container spacing={2}>
 <Grid item xs={12} sm={6} md={4}>Card 1</Grid>
 <Grid item xs={12} sm={6} md={4}>Card 2</Grid>
 <Grid item xs={12} sm={6} md={4}>Card 3</Grid>
</Grid>

15. How to create a Dialog (Popup) in MUI?

Dialog is used for popups and modals.

const [open, setOpen] = useState(false);

<Button onClick={() => setOpen(true)}>Open Dialog</Button>

<Dialog open={open} onClose={() => setOpen(false)}>
 <DialogTitle>Alert</DialogTitle>
 <DialogContent>This is a popup.</DialogContent>
</Dialog>

16. How to use Flexbox with MUI Box?

MUI Box supports flexbox properties directly with sx.

<Box sx={{ display: "flex", gap: 2 }}>
 <Button variant="contained">One</Button>
 <Button variant="contained">Two</Button>
</Box>

17. How to create a custom theme color?

MUI allows you to add your own color palette.

import { ThemeProvider, createTheme } from "@mui/material/styles";
import Button from "@mui/material/Button";

const theme = createTheme({
  palette: {
    myBlue: { main: "#0077ff" }
  }
});

<ThemeProvider theme={theme}>
  <Button color="myBlue" variant="contained">Blue</Button>
</ThemeProvider>

18. How to add icons inside Buttons?

MUI icons can be placed inside buttons using startIcon or endIcon.

import SendIcon from "@mui/icons-material/Send";

<Button variant="contained" endIcon={} >
 Send
</Button>

19. How to create a Card with an Image?

CardMedia helps display images inside a Card.

<Card sx={{ maxWidth: 300 }}>
 <CardMedia
  component="img"
  height="160"
  image="https://via.placeholder.com/300"
 />
 <CardContent>Sample Image Card</CardContent>
</Card>

20. How to create a simple Navbar with AppBar?

AppBar and Toolbar help create a clean navigation bar.

<AppBar position="static">
 <Toolbar sx={{ display: "flex", justifyContent: "space-between" }}>
  Logo
  <Button color="inherit">Login</Button>
 </Toolbar>
</AppBar>

21. What are MUI Breakpoints?

Breakpoints help create responsive designs for mobile, tablet, and desktop using preset sizes like xs, sm, md, lg, xl.

<Box sx={{ width: { xs: "100%", sm: "70%", md: "50%" } }}>
 Responsive Box
</Box>

22. What is useTheme() in MUI?

useTheme() lets you access the current theme inside components.

const theme = useTheme();

<Box sx={{ color: theme.palette.primary.main }}>
 Themed Text
</Box>

23. What is responsive Typography?

MUI allows text to scale automatically based on screen size.

<Typography variant="h4" sx={{ fontSize: { xs: "20px", md: "32px" } }}>
 Responsive Heading
</Typography>

24. How to override default MUI component styles?

You can override default styles using theme.components.

const theme = createTheme({
 components: {
  MuiButton: {
   styleOverrides: {
    root: { borderRadius: "12px" }
   }
  }
 }
});

25. What is Stack in MUI?

Stack is used to arrange items vertically or horizontally with spacing.

<Stack direction="row" spacing={2}>
 <Button>One</Button>
 <Button>Two</Button>
</Stack>

26. How to create Tabs in MUI?

Tabs help switch between multiple views.

const [value, setValue] = useState(0);

<Tabs value={value} onChange={(e, v) => setValue(v)}>
 <Tab label="Home" />
 <Tab label="Profile" />
</Tabs>
⬅ Home