我是React和Material UI的新手,我试图通过使用createMuiTheme向MUI按钮添加一些自定义样式。
我已经按照文档进行了操作,并复制了示例,但是它没有效果,并且在控制台中没有抛出任何错误。
我已经对此打了一段时间,我看不出问题是什么,我想念什么?
import React from 'react';
import { createMuiTheme } from '@material-ui/core/styles';
import { ThemeProvider } from '@material-ui/styles';
import Button from '@material-ui/core/Button';
const mytheme = createMuiTheme({
palette: {
primary: { main: '#1565C0'},
secondary: { main: '#11cb5f' },
},
});
export const PrimaryButton = (props) => {
return (
<ThemeProvider theme={mytheme}>
<a href={props.buttonLink}>
<Button
style={{ ...props.styles}}
onClick={props.handleClick}
variant='contained' color='primary' size='large'
>
{props.buttonText}
</Button>
</a>
</ThemeProvider>
);
};
export const SecondaryButton = (props) => {
return (
<ThemeProvider theme={mytheme}>
<Button
style={{...props.styles }}
value={props.value || ''}
onClick={props.handleClick}
variant='outlined' color='secondary' size='large'
>
{props.buttonText}
</Button>
</ThemeProvider>
)
}
答案 0 :(得分:0)
正在工作。尝试更改此内容:
variant='outlined'
作者
variant='contained'