<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TimelineView",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12TimelineViewV"
  },
  "title" : "TimelineView"
}
-->

# TimelineView

A view that updates according to a schedule that you provide.

```
struct TimelineView<Schedule, Content> where Schedule : TimelineSchedule
```

## Overview

A timeline view acts as a container with no appearance of its own. Instead,
it redraws the content it contains at scheduled points in time.
For example, you can update the face of an analog timer once per second:

```
TimelineView(.periodic(from: startDate, by: 1)) { context in
    AnalogTimerView(date: context.date)
}
```

The closure that creates the content receives an input of type [`TimelineView.Context`](/documentation/SwiftUI/TimelineView/Context)
that you can use to customize the content’s appearance. The context includes
the [`date`](/documentation/SwiftUI/TimelineView/Context/date) that triggered the update. In the example above,
the timeline view sends that date to an analog timer that you create so the
timer view knows how to draw the hands on its face.

The context also includes a [`cadence`](/documentation/SwiftUI/TimelineView/Context/cadence-swift.property)
property that you can use to hide unnecessary detail. For example, you
can use the cadence to decide when it’s appropriate to display the
timer’s second hand:

```
TimelineView(.periodic(from: startDate, by: 1.0)) { context in
    AnalogTimerView(
        date: context.date,
        showSeconds: context.cadence <= .seconds)
}
```

The system might use a cadence that’s slower than the schedule’s
update rate. For example, a view on watchOS might remain visible when the
user lowers their wrist, but update less frequently, and thus require
less detail.

You can define a custom schedule by creating a type that conforms to the
[`TimelineSchedule`](/documentation/SwiftUI/TimelineSchedule) protocol, or use one of the built-in schedule types:

- Use an [`everyMinute`](/documentation/SwiftUI/TimelineSchedule/everyMinute) schedule to update at the
  beginning of each minute.
- Use a [`periodic(from:by:)`](/documentation/SwiftUI/TimelineSchedule/periodic(from:by:)) schedule to update
  periodically with a custom start time and interval between updates.
- Use an [`explicit(_:)`](/documentation/SwiftUI/TimelineSchedule/explicit(_:)) schedule when you need a finite number, or
  irregular set of updates.

For a schedule containing only dates in the past,
the timeline view shows the last date in the schedule.
For a schedule containing only dates in the future,
the timeline draws its content using the current date
until the first scheduled date arrives.

## Topics

### Creating a timeline

[`init(_:content:)`](/documentation/SwiftUI/TimelineView/init(_:content:)-1mlmj)

Creates a new timeline view that uses the given schedule.

[`Context`](/documentation/SwiftUI/TimelineView/Context)

Information passed to a timeline view’s content callback.

### Deprecated symbols

[`init(_:content:)`](/documentation/SwiftUI/TimelineView/init(_:content:)-67h35)

Creates a new timeline view that uses the given schedule.

## Relationships

### Conforms To

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

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

[`View`](/documentation/SwiftUI/View)

---

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)