<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Spring",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6SpringV"
  },
  "title" : "Spring"
}
-->

# Spring

A representation of a spring’s motion.

```
struct Spring
```

## Overview

Use this type to convert between different representations of spring
parameters:

```
let spring = Spring(duration: 0.5, bounce: 0.3)
let (mass, stiffness, damping) = (spring.mass, spring.stiffness, spring.damping)
// (1.0, 157.9, 17.6)

let spring2 = Spring(mass: 1, stiffness: 100, damping: 10)
let (duration, bounce) = (spring2.duration, spring2.bounce)
// (0.63, 0.5)
```

You can also use it to query for a spring’s position and its other properties for
a given set of inputs:

```
func unitPosition(time: TimeInterval) -> Double {
    let spring = Spring(duration: 0.5, bounce: 0.3)
    return spring.position(target: 1.0, time: time)
}
```

## Topics

### Creating a spring

[`init(duration:bounce:)`](/documentation/SwiftUI/Spring/init(duration:bounce:))

Creates a spring with the specified duration and bounce.

[`init(mass:stiffness:damping:allowOverDamping:)`](/documentation/SwiftUI/Spring/init(mass:stiffness:damping:allowOverDamping:))

Creates a spring with the specified mass, stiffness, and damping.

[`init(response:dampingRatio:)`](/documentation/SwiftUI/Spring/init(response:dampingRatio:))

Creates a spring with the specified response and damping ratio.

[`init(settlingDuration:dampingRatio:epsilon:)`](/documentation/SwiftUI/Spring/init(settlingDuration:dampingRatio:epsilon:))

Creates a spring with the specified duration and damping ratio.

### Getting built-in springs

[`bouncy`](/documentation/SwiftUI/Spring/bouncy)

A spring with a predefined duration and higher amount of bounce.

[`bouncy(duration:extraBounce:)`](/documentation/SwiftUI/Spring/bouncy(duration:extraBounce:))

A spring with a predefined duration and higher amount of bounce that
can be tuned.

[`smooth`](/documentation/SwiftUI/Spring/smooth)

A smooth spring with a predefined duration and no bounce.

[`smooth(duration:extraBounce:)`](/documentation/SwiftUI/Spring/smooth(duration:extraBounce:))

A smooth spring with a predefined duration and no bounce that can be
tuned.

[`snappy`](/documentation/SwiftUI/Spring/snappy)

A spring with a predefined duration and small amount of bounce that
feels more snappy.

[`snappy(duration:extraBounce:)`](/documentation/SwiftUI/Spring/snappy(duration:extraBounce:))

A spring with a predefined duration and small amount of bounce that
feels more snappy and can be tuned.

### Getting spring characteristics

[`bounce`](/documentation/SwiftUI/Spring/bounce)

How bouncy the spring is.

[`damping`](/documentation/SwiftUI/Spring/damping)

Defines how the spring’s motion should be damped due to the forces of
friction.

[`dampingRatio`](/documentation/SwiftUI/Spring/dampingRatio)

The amount of drag applied, as a fraction of the amount needed to
produce critical damping.

[`duration`](/documentation/SwiftUI/Spring/duration)

The perceptual duration, which defines the pace of the spring.

[`mass`](/documentation/SwiftUI/Spring/mass)

The mass of the object attached to the end of the spring.

[`response`](/documentation/SwiftUI/Spring/response)

The stiffness of the spring, defined as an approximate duration in
seconds.

[`settlingDuration`](/documentation/SwiftUI/Spring/settlingDuration)

The estimated duration required for the spring system to be considered
at rest.

[`stiffness`](/documentation/SwiftUI/Spring/stiffness)

The spring stiffness coefficient.

### Getting spring state

[`value(target:initialVelocity:time:)`](/documentation/SwiftUI/Spring/value(target:initialVelocity:time:))

Calculates the value of the spring at a given time given a target
amount of change.

[`value(fromValue:toValue:initialVelocity:time:)`](/documentation/SwiftUI/Spring/value(fromValue:toValue:initialVelocity:time:))

Calculates the value of the spring at a given time for a starting
and ending value for the spring to travel.

[`velocity(target:initialVelocity:time:)`](/documentation/SwiftUI/Spring/velocity(target:initialVelocity:time:))

Calculates the velocity of the spring at a given time given a target
amount of change.

[`velocity(fromValue:toValue:initialVelocity:time:)`](/documentation/SwiftUI/Spring/velocity(fromValue:toValue:initialVelocity:time:))

Calculates the velocity of the spring at a given time given a starting
and ending value for the spring to travel.

### Setting spring state

[`update(value:velocity:target:deltaTime:)`](/documentation/SwiftUI/Spring/update(value:velocity:target:deltaTime:))

Updates the current  value and velocity of a spring.

### Calculating forces and durations

[`force(target:position:velocity:)`](/documentation/SwiftUI/Spring/force(target:position:velocity:))

Calculates the force upon the spring given a current position, target,
and velocity amount of change.

[`force(fromValue:toValue:position:velocity:)`](/documentation/SwiftUI/Spring/force(fromValue:toValue:position:velocity:))

Calculates the force upon the spring given a current position,
velocity, and divisor from the starting and end values for the spring to travel.

[`settlingDuration(target:initialVelocity:epsilon:)`](/documentation/SwiftUI/Spring/settlingDuration(target:initialVelocity:epsilon:))

The estimated duration required for the spring system to be considered
at rest.

[`settlingDuration(fromValue:toValue:initialVelocity:epsilon:)`](/documentation/SwiftUI/Spring/settlingDuration(fromValue:toValue:initialVelocity:epsilon:))

The estimated duration required for the spring system to be considered
at rest.

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Hashable`](/documentation/Swift/Hashable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)