Вы можете передать оттенок непосредственно в свойство style :
import red from "@material-ui/core/colors/red";
const primaryLight = red["A100"];
...
<Button variant="contained" style={{ backgroundColor: primaryLight }}>click</Button>
Или, если хотите создать тему :
index.js
import React from "react";
import ReactDOM from "react-dom";
import { createMuiTheme } from "@material-ui/core/styles";
import { ThemeProvider } from "@material-ui/styles";
import red from "@material-ui/core/colors/red";
import MyComponent from "./MyComponent";
const primary = red[500];
const primaryLight = red["A100"];
const theme = createMuiTheme({
palette: {
primary: {
light: primaryLight,
main: primary
}
}
});
function App() {
return (
<ThemeProvider theme={theme}>
<div className="App">
<MyComponent />
</div>
</ThemeProvider>
);
}
Mycomponent.js
import React from "react";
import { useTheme } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
function MyComponent() {
const theme = useTheme();
const primaryLight = theme.palette.primary.light;
const styles = {
button: {
backgroundColor: primaryLight,
},
}
return (
<Button variant="contained" style={styles.button}>click</Button>
)
}
export default MyComponent;
Демо:
