Animation & Timing
useSpring
A hook that animates a value using spring physics.
useSpring
useSpring is a hook that animates a value using spring physics. It simulates a spring force to move a value towards a target.
Usage
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| targetValue | number | - | The value to animate towards. |
| config | SpringConfig | Configuration object for the spring. |
SpringConfig
| Property | Type | Default | Description |
|---|---|---|---|
| stiffness | number | 170 | Spring stiffness. Higher values create a snappier spring. |
| damping | number | 26 | Spring damping. Higher values reduce oscillation. |
| mass | number | 1 | Mass of the object attached to the spring. |
| precision | number | 0.01 | Precision threshold to stop the animation. |
Return Value
Returns the current animated value.