Skip to main content

Overview

The tweened 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

value
T
default:"undefined"
The initial value of the store
options
TweenedOptions<T>
default:"{}"
Configuration options for the tween behavior

Return Value

Returns a Tweened<T> store object with:
  • subscribe(fn) - Subscribe to value changes
  • set(value, options?) - Set a new value and return a Promise that resolves when the tween completes
  • update(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 for tweened() 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 })
Values must be of the same type. Attempting to tween between different types (e.g., number to array) will throw an error.

Common Easing Functions

Import from svelte/easing:

See Also