在 createMuiTheme 中访问以前的主题变量
Accessing previous theme variables in createMuiTheme
运行 Material UI 1.0.0-beta.24
我正在使用 createMuiTheme
设置新主题:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: 16
}
});
export default theme;
如何直接在此处访问我正在覆盖的主题?
我想这样做,但行不通:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: theme.typography.fontSize + 2
}
});
export default theme;
您需要创建默认主题的实例并在定义您自己的主题时使用它:
import { createMuiTheme } from 'material-ui/styles';
const defaultTheme = createMuiTheme();
const theme = createMuiTheme({
typography: {
fontSize: defaultTheme.typography.fontSize + 2
}
});
export default theme;
您也可以创建自己的主题,然后在 theme
创建后添加到主题中。
import { createMuiTheme } from 'material-ui/styles';
const theme = createMuiTheme();
theme.typography = {
...theme.typography,
fontSize: theme.typography.fontSize + 2
}
export default theme;
运行 Material UI 1.0.0-beta.24
我正在使用 createMuiTheme
设置新主题:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: 16
}
});
export default theme;
如何直接在此处访问我正在覆盖的主题? 我想这样做,但行不通:
import {createMuiTheme} from 'material-ui/styles';
const theme = createMuiTheme({
typography: {
fontSize: theme.typography.fontSize + 2
}
});
export default theme;
您需要创建默认主题的实例并在定义您自己的主题时使用它:
import { createMuiTheme } from 'material-ui/styles';
const defaultTheme = createMuiTheme();
const theme = createMuiTheme({
typography: {
fontSize: defaultTheme.typography.fontSize + 2
}
});
export default theme;
您也可以创建自己的主题,然后在 theme
创建后添加到主题中。
import { createMuiTheme } from 'material-ui/styles';
const theme = createMuiTheme();
theme.typography = {
...theme.typography,
fontSize: theme.typography.fontSize + 2
}
export default theme;