Rom*_*tit 9 theming reactjs material-ui jss
运行材质UI 1.0.0-beta.24
我正在使用createMuiTheme以下方式设置新主题:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: 16
}
});
export default theme;
Run Code Online (Sandbox Code Playgroud)
我怎样才能直接访问我直接覆盖的主题?我想这样做,这是行不通的:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: theme.typography.fontSize + 2
}
});
export default theme;
Run Code Online (Sandbox Code Playgroud)
Ken*_*ory 26
您需要创建默认主题的实例,并在定义自己的主题时使用它:
import { createMuiTheme } from 'material-ui/styles';
const defaultTheme = createMuiTheme();
const theme = createMuiTheme({
typography: {
fontSize: defaultTheme.typography.fontSize + 2
}
});
export default theme;
Run Code Online (Sandbox Code Playgroud)
您也可以创建您的主题,然后在theme创建后添加到它。
import { createMuiTheme } from 'material-ui/styles';
const theme = createMuiTheme();
theme.typography = {
...theme.typography,
fontSize: theme.typography.fontSize + 2
}
export default theme;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1712 次 |
| 最近记录: |