How to change mui icons background color in react js?
November 19, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
To change mui icons background color, set background-color: aqua !important;
in MuiIconButton-root
. It will change mui icons background color.
To change the mui icon background color with inline css, this code has to be written
sx={{ color: "white", background Color: "#784734",}}
.
Today, I am going to show you, How to change mui icons background color in react js.
Installation
Install the following packages to use mui icon in react js.
npm
npm install @mui/material @emotion/react @emotion/styled
yarn
yarn add @mui/material @emotion/react @emotion/styled
MUI material changed icons background color example.
The below code is an example of changing icons background color using mui.
App.js
import * as React from 'react';
import Stack from '@mui/material/Stack';
import IconButton from '@mui/material/IconButton';
import ArrowForwardIcon from '@mui/icons-material/ArrowForward';
import "./App.css"
export default function IconButtonSizes() {
return (
<Stack direction="row" alignItems="center" spacing={1}>
<IconButton aria-label="delete" sx={{
color: "white",
backgroundColor: "#784734",
borderRadius: "50%"
}}>
<ArrowForwardIcon />
</IconButton>
</Stack>
);
}
App.css
.MuiIconButton-root {
background-color: aqua !important;
}
In the above code example, I have used the @mui/material
icons component and changed mui icons background color.
Check the output of the above code example.
All the best 👍