访问createMuiTheme中的先前主题变量 [英] Accessing previous theme variables in createMuiTheme

查看:147
本文介绍了访问createMuiTheme中的先前主题变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行材料界面 1.0.0-beta.24

我正在使用createMuiTheme设置新主题:

I'm setting a new theme using createMuiTheme:

import {createMuiTheme} from 'material-ui/styles';

const theme = createMuiTheme({
  typography: {
    fontSize: 16
  }
});

export default theme;

如何才能在此处直接访问要覆盖的主题? 我想这样做,但不起作用:

How can I access the theme I'm overriding directly here ? I'd like to do this, which is not working :

import {createMuiTheme} from 'material-ui/styles';

const theme = createMuiTheme({
  typography: {
    fontSize: theme.typography.fontSize + 2
  }
});

export default theme;

推荐答案

您需要创建默认主题的实例,并在定义自己的主题时使用它:

You'd need to create an instance of the default theme and use it when defining your own:

import { createMuiTheme } from 'material-ui/styles';

const defaultTheme = createMuiTheme();

const theme = createMuiTheme({
  typography: {
    fontSize: defaultTheme.typography.fontSize + 2
  }
});

export default theme;

这篇关于访问createMuiTheme中的先前主题变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆