reactjs - 更改 MUI React 中的涟漪效果持续时间
问题描述
我想修改主题文件中的涟漪效果持续时间
我试过像
const theme = createMuiTheme({
props: {
MuiButtonBase: {
TouchRippleProps: {
animationDuration: '5s',
transitionDuration: '5s',
},
classes: {
root: 'CustomizeTouchRipple'
}
},
}
})
不工作..但添加类
编辑:
TouchRipple
我发现它在组件
中是一个常量https://github.com/mui-org/material-ui/blob/c06a88d24235685dd769c1a3df82152ded17a6ca/packages/material-ui/src/ButtonBase/TouchRipple.js#L8
解决方案
从源码来看,设置的类名animationDuration
是MuiTouchRipple-rippleVisible
。您只需要覆盖该值:
V5
<Button
sx={{
'&& .MuiTouchRipple-rippleVisible': {
animationDuration: '200ms',
},
}}
>
V4
const theme = createTheme({
overrides: {
MuiButton: {
root: {
'& .MuiTouchRipple-rippleVisible': {
animationDuration: '200ms',
},
},
},
// if you want to change the ripple duration of all components that have ripple
// effect (e.g. Button, CardActionArea, FAB...)
MuiTouchRipple: {
rippleVisible: {
animationDuration: '200ms',
},
},
},
});
推荐阅读
- python-3.x - 如何在 django 的管理员中将此模型转换为不可编辑的模型?
- android - 如果没有从方向旋转重新创建活动,如何执行代码?
- spring-data-jpa - JPA 中的联合和使用别名
- c# - Reference.svcmap:无法加载文件或程序集“Microsoft.SqlServer.SqlEnum,
- typescript - 解析错误:将文件重命名为 ts 后应出现“>”
- java - Spring-boot WebMvcTest,当我提供一个模拟的UserDetailsService时,为什么我会得到这个NullPointer?
- javascript - 试图了解如何通过 webpack 导入 web-assembly 包
- postgresql - 错误:在“ALL”postgres GRANT psql 8.4.15 处或附近出现语法错误
- python - Kivy:GridLayout 中的奇数标签间距
- matlab - 编译后无法在 UIFigure 中选择数据点