📱

WidgetKit

iOS 14+

Build home screen and lock screen widgets using SwiftUI. WidgetKit provides a unified API for creating glanceable, personalized widgets across iOS, iPadOS, and macOS.

UI
Official Apple Documentation →
iOS Version Compatibility
97.1%
coverage

of iOS users worldwide can use WidgetKit (iOS 14+ required)

iOS VersionMarket ShareStatus
iOS 18.730.3%Supported
iOS 18.629.8%Supported
iOS 26.110.7%Supported
iOS 18.56.0%Supported
iOS 16.72.3%Supported
iOS 26.22.0%Supported
iOS 18.31.8%Supported
iOS 15.81.8%Supported
iOS 17.61.7%Supported
iOS 26.01.3%Supported

Key Features

Build widgets entirely with SwiftUI

Support for multiple widget sizes

Timeline-based content updates

Lock screen widget support (iOS 16+)

App Intents for interactive widgets (iOS 17+)

Home screen and StandBy mode support

Code Examples

Define a Widget

Create a basic widget using WidgetKit and SwiftUI

import WidgetKit
import SwiftUI

struct SimpleWidget: Widget {
    let kind: String = "SimpleWidget"
    
    var body: some WidgetConfiguration {
        StaticConfiguration(kind: kind, provider: Provider()) { entry in
            SimpleWidgetEntryView(entry: entry)
        }
        .configurationDisplayName("My Widget")
        .description("This is an example widget.")
        .supportedFamilies([.systemSmall, .systemMedium, .systemLarge])
    }
}

Create a Timeline Provider

Provide timeline entries to update widget content

import WidgetKit

struct Provider: TimelineProvider {
    func placeholder(in context: Context) -> SimpleEntry {
        SimpleEntry(date: Date(), text: "Placeholder")
    }
    
    func getSnapshot(in context: Context, completion: @escaping (SimpleEntry) -> ()) {
        let entry = SimpleEntry(date: Date(), text: "Snapshot")
        completion(entry)
    }
    
    func getTimeline(in context: Context, completion: @escaping (Timeline<Entry>) -> ()) {
        var entries: [SimpleEntry] = []
        
        let currentDate = Date()
        for hourOffset in 0 ..< 5 {
            let entryDate = Calendar.current.date(byAdding: .hour, value: hourOffset, to: currentDate)!
            let entry = SimpleEntry(date: entryDate, text: "Hour \(hourOffset)")
            entries.append(entry)
        }
        
        let timeline = Timeline(entries: entries, policy: .atEnd)
        completion(timeline)
    }
}

struct SimpleEntry: TimelineEntry {
    let date: Date
    let text: String
}

Widget View

Display widget content with SwiftUI

import SwiftUI
import WidgetKit

struct SimpleWidgetEntryView: View {
    var entry: Provider.Entry
    
    var body: some View {
        VStack {
            Text(entry.date, style: .time)
                .font(.headline)
            Text(entry.text)
                .font(.caption)
        }
        .containerBackground(.fill.tertiary, for: .widget)
    }
}

Frequently Asked Questions

What is WidgetKit?

Build home screen and lock screen widgets using SwiftUI. WidgetKit provides a unified API for creating glanceable, personalized widgets across iOS, iPadOS, and macOS.

Which iOS versions support WidgetKit?

WidgetKit is available on iOS 14 and later. Currently, 97.1% of iOS users worldwide can use this framework.

What are alternatives to WidgetKit?

Related frameworks include Swiftui, Appintents. Each has different capabilities and iOS version requirements.