So far in the API (v3.9.2
), I see a mention of TouchRippleProps
for ButtonBase
for https://material-ui.com/api/button-base/
My but
It doesn't appear animations other than the ripple are supported. However, you can create something like this TriggeredAnimation
wrapper component:
class TriggeredAnimationWrapper extends Component {
constructor(...args) {
super(...args)
this.state = {
wasClicked: false
}
this.triggerAnimation = this.triggerAnimation.bind(this)
}
triggerAnimation(callback) {
return (...args) => {
this.setState(
{wasClicked: true},
() => requestAnimationFrame(()=>this.setState({wasClicked: false}))
)
if (callback) return callback(...args)
}
}
render() {
const {
triggerAnimation,
props: {
children
},
state: {
wasClicked
}
} = this.props
return children({wasClicked, triggerAnimation})
}
}
And use it like this:
({wasClicked, triggerAnimation}) => (
Then, you can create a css animation and change the background when the click class is present.