Skip to main content
Easing functions specify the rate of change over time, transforming linear time values into curves that feel more natural. Svelte provides a comprehensive set of easing functions adapted from mattdesl’s easing library.

Signature

t
number
required
A value between 0 and 1 representing the progress of the animation
return
number
The eased value, typically between 0 and 1 (some easing functions like elastic and back may exceed this range)

Usage

Easing functions are commonly used with transitions and animations:

Available Functions

linear

No easing, constant rate of change.

Quadratic (quad)

Acceleration using a quadratic curve (t²).

Cubic

Acceleration using a cubic curve (t³). Recommended for most UI animations.

Quartic (quart)

Acceleration using a quartic curve (t⁴).

Quintic (quint)

Acceleration using a quintic curve (t⁵).

Sinusoidal (sine)

Acceleration using a sinusoidal curve. Provides very smooth, gentle easing.

Exponential (expo)

Acceleration using an exponential curve (2^t). Creates dramatic acceleration.

Circular (circ)

Acceleration using a circular curve (sqrt). Sharp acceleration at the end.

Back

Overshoots the target value before settling. Creates a “wind-up” effect.

Elastic

Creates an elastic, spring-like oscillation. More pronounced than back.

Bounce

Bouncing effect, like a ball landing.

Easing Variants

Most easing functions come in three variants:
  • In: Starts slow and accelerates (easing at the beginning)
  • Out: Starts fast and decelerates (easing at the end)
  • InOut: Combines both, easing at the beginning and end
For most UI animations, Out or InOut variants feel more natural and responsive.

Creating Custom Easing

You can create custom easing functions:

Notes

  • All easing functions accept a value t between 0 and 1
  • Some functions (elastic, back, bounce) may return values outside the 0-1 range
  • For most UI animations, cubicOut or cubicInOut provide good defaults
  • Easing functions are pure and have no side effects
  • The library is adapted from mattdesl’s work, distributed under MIT License

See Also