The material-ripple hook for React that actually works
npm install use-wave
The material-ripple hook for React that actually works
pointerdown instead of pointerup
width and height.
display: flex).
currentColor).
border-radius: 5px 20px 15px 30px) perfectly fine.
sh
$ npm i use-wave
`
or
CDN
`html
`
Usage
`jsx
import useWave from 'use-wave'
function MyComponent() {
const wave = useWave()
return
}
`
It is possible to reuse a single wave for multiple elements
`jsx
import useWave from 'use-wave'
function List() {
const wave = useWave()
const items = ['item 1', 'item 2', 'item 2']
return (
<>
Home
{items.map(item => - {item}
)}
>
)
}
`
Options
#### Usage with options
`js
useWave({
color: 'red',
startingOpacity: 0.5,
easing: 'ease-in',
})
`
#### Global options
`js
// your/hooks/directory/use-custom-wave.js
export const useCustomWave = (overrides = {}) => {
const defaults = {color: 'red'} // your custom global options
return useWave({...defaults, ...overrides})
}
`
$3
| Name | Type | Default |
| -------------------- | -------- | :--------------: |
| color | string | "currentColor" |
| initialOpacity | number | 0.2 |
| finialOpacity | number | 0.1 |
| duration | number | 0.4 |
| easing | string | ease-out |
| cancellationPeriod | number | 75 |
$3
#### color
- type: string
- default: "currentColor"
The background-color of the wave.
#### initialOpacity
- type: number
- default: 0.2
The opacity of the wave when it first appears.
#### finalOpacity
- type: number
- default: 0.1
The opacity the wave should be when it has stopped moving.
#### duration
- type: number
- default: 0.4
The duration of the wave animation in seconds.
#### easing
- type: string
- default: "ease-out"
Any valid CSS
#### cancellationPeriod
- type: number
- default: 75`