<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WidgetKit",
  "identifier" : "/documentation/WidgetKit/TimelineProviderContext",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "WidgetKit"
    ],
    "preciseIdentifier" : "s:9WidgetKit23TimelineProviderContextV"
  },
  "title" : "TimelineProviderContext"
}
-->

# TimelineProviderContext

An object that contains details about how a widget is rendered, including
its size and whether it appears in the widget gallery.

```
struct TimelineProviderContext
```

## Overview

When requesting timelines for a widget, WidgetKit passes the
[`TimelineProvider`](/documentation/WidgetKit/TimelineProvider) a context object that includes details about how
the widget appears. These details include:

- The [`WidgetFamily`](/documentation/WidgetKit/WidgetFamily); for example, [`WidgetFamily.systemSmall`](/documentation/WidgetKit/WidgetFamily/systemSmall) and  [`WidgetFamily.systemMedium`](/documentation/WidgetKit/WidgetFamily/systemMedium).
- The size, in points, of the widget.
- Variants of the environments where the widget might appear.
- Whether the widget appears as a preview in the widget gallery.

If your widget uses assets that take time to generate or depend on the specific
environment they’re rendered in, you can use the environment variants to
generate those assets in advance. Some of the common environment properties
to consider include:

- <doc://com.apple.documentation/documentation/SwiftUI/EnvironmentValues/colorScheme>, where you use different assets for light and dark schemes.
- <doc://com.apple.documentation/documentation/SwiftUI/EnvironmentValues/displayScale>, where your widget might appear in both @1x and @2x
  displays on macOS devices.

To be responsive when the environment changes, WidgetKit may render the
widget’s view in advance. For example, WidgetKit renders both light and
dark versions of the widget so that if the color scheme changes, the correct
version is immediately available.

## Topics

### Preparing Preview Content

[`isPreview`](/documentation/WidgetKit/TimelineProviderContext/isPreview)

A Boolean value that indicates when the widget appears in the widget gallery.

### Accessing Size Attributes

[`family`](/documentation/WidgetKit/TimelineProviderContext/family)

The user-configured family of the widget: small, medium, or large.

[`displaySize`](/documentation/WidgetKit/TimelineProviderContext/displaySize)

The size, in points, of the widget.

### Accessing Environment Variations

[`environmentVariants`](/documentation/WidgetKit/TimelineProviderContext/environmentVariants-swift.property)

All environment values that might be set when a widget appears.

[`TimelineProviderContext.EnvironmentVariants`](/documentation/WidgetKit/TimelineProviderContext/EnvironmentVariants-swift.struct)

A structure containing all varieties of environments where a widget
could appear.



---

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)