Overview
Thetweened store provides smooth transitions between state values over time. Unlike regular stores that update instantly, tweened stores animate from one value to another using configurable duration and easing functions.
Deprecated: The
tweened() function is deprecated in Svelte 5. Use the Tween class instead.Import
Signature (Legacy)
Parameters
The initial value of the store
Configuration options for the tween behavior
Return Value
Returns aTweened<T> store object with:
subscribe(fn)- Subscribe to value changesset(value, options?)- Set a new value and return a Promise that resolves when the tween completesupdate(fn, options?)- Update the value using a callback function
Examples
Basic Number Tween
Using Different Easing Functions
Dynamic Duration
Tweening Objects
Awaiting Completion
Per-Call Options
New Tween Class (Svelte 5+)
The modern replacement fortweened() is the Tween class:
Reactive Tween with Tween.of()
Supported Value Types
The tweened store can interpolate:- Numbers:
tweened(0)→tweened(100) - Dates:
tweened(new Date(2024, 0, 1))→tweened(new Date(2024, 11, 31)) - Arrays:
tweened([0, 0])→tweened([100, 200]) - Objects:
tweened({ x: 0, y: 0 })→tweened({ x: 100, y: 100 })
Common Easing Functions
Import fromsvelte/easing:
See Also
- spring - For physics-based animations
- Svelte Easing - Available easing functions
- Tween Class - Modern replacement