在我们当前的react应用程序中,我们使用的是material v4,我们有以下定制风格:
const useStyles = makeStyles((theme) =>
createStyles({
dob: {
color: theme.palette.grey[300],
},
location: {
color: theme.palette.grey[300],
},
})
)在我们的组成部分中,我们
<Box>
...
<Typography className={classes.dob} variant="caption">
{formatDateTime(
person.dateOfBirth,
"M/D/YYYY HH:mm:ss A"
)}
</Typography>
<Typography className={classes.location} variant="caption">
{props.person.location}
</Typography>
...
</Box>现在我们正在升级到v5。在迁移指南中,它建议使用sx,但是我在主题上出现了一个错误。
<Typography sx={{theme.palette.grey[300]}} variant="caption">
{props.person.location}
</Typography>有谁知道我该怎么解决这个问题吗?此外,我想知道是否可以使用styled()来在诸如Box、Appbar等重要ui组件上创建自定义样式。指南中提供的示例仅用于泛型html元素,例如div、span。例如:
const MyTypograhy = styled('Typography')(({ theme }) => ({
color: theme.palette.primary.main,
}))发布于 2022-09-09 03:21:31
https://stackoverflow.com/questions/73656952
复制相似问题