2 回答

TA貢獻(xiàn)1815條經(jīng)驗(yàn) 獲得超6個(gè)贊
它是這樣完成的。
createMuiTheme({
palette: {
...,
text: {
primary: styles.t,
secondary: styles.tt,
disabled: styles.ttt,
hint: styles.tttt,
},
...
}
...
}
確保那primary是color code,而不是object。顏色可以這樣使用
<Typography
color='textPrimary'> // or 'textSecondary', 'hint', 'disabled'
Foo Bar
</Typography>

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超6個(gè)贊
如果要更改“material-ui”Typography 組件的默認(rèn)顏色,可以使用這種代碼。
import { createMuiTheme, ThemeProvider, Typography } from '@material-ui/core';
const MuiTheme = createMuiTheme({
typography: {
allVariants: {
color: 'red'
}
}
});
const App = () => {
return (
<ThemeProvider theme={MuiTheme}>
<Typography>Hi there</Typography>
</ThemeProvider>
);
};
export default App;
這會(huì)將 Typography 組件的默認(rèn)顏色更改為您想要的任何顏色(對(duì)于此示例,它使默認(rèn)顏色為紅色),當(dāng)然它會(huì)通過在 Typography 組件中使用“color”屬性來更改。
添加回答
舉報(bào)