One Logo Pool Ball
WidgetKit · IOS API REFERENCE

TimelineProviderContext

struct · iOS 14.0+ · SDK 27.1

struct TimelineProviderContext

An object that contains details about how a widget is rendered, including its size and whether it appears in the widget gallery. When requesting timelines for a widget, WidgetKit passes the <doc:TimelineProvider> a context object that includes details about how the widget appears. These details include: * The <doc:WidgetKit/WidgetFamily>; for example, <doc:WidgetKit/WidgetFamily/systemSmall> and <doc: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.

Members (4)

get · iOS 14.0+

displaySize

TypeScript
get displaySize(): { width: number; height: number }
Swift declaration
let displaySize: CGSize

The size, in points, of the widget.

get · iOS 14.0+

environmentVariants

TypeScript
get environmentVariants(): TimelineProviderContext_EnvironmentVariants
Swift declaration
let environmentVariants: TimelineProviderContext.EnvironmentVariants

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

get · iOS 14.0+

family

TypeScript
get family(): WidgetFamily
Swift declaration
let family: WidgetFamily

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

get · iOS 14.0+

isPreview

TypeScript
get isPreview(): boolean
Swift declaration
let isPreview: Bool

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

Skipped declarations

No declarations were skipped in this snapshot.

All WidgetKit types →