Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Apple docs
FeedbackApple

Timer

Display absolute-clock countdowns and elapsed time with controlled announcement frequency.

Public APILumenTimerApple / SwiftUISwift product: LumenUI

Apple availability

Supported native targets

Import LumenUI in the target that uses this component. iPad support follows the iOS package baseline and uses native iPad layout behavior.

iPhone · iOS 16+iPad · iPadOS 16+Mac · macOS 13+Apple TV · tvOS 16+Apple Vision · visionOS 1+Apple Watch · watchOS 9+

Native example

Use Timer

Keep the target instant in host state. Backgrounding pauses updates while absolute time continues. Invalid targets show a placeholder; countdowns stop at zero and report completion once after running. The timer uses no animation.

Timer rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulatorView dark appearance
swift
struct CountdownExample: View {
    @State private var deadline = Date().addingTimeInterval(65)
    var body: some View {
        LumenTimer("Time remaining", to: deadline,
                   units: [.minutes, .seconds], announce: .complete,
                   completeLabel: "Countdown finished")
    }
}

Reference

Public API

The primary shared and platform-specific options exposed by LumenTimer.

APIValues or typeDefaultDescription
labelLocalized stringRequiredNames the timer independently of its changing digits.
modecountdown · elapsedcountdownCounts toward to or from the elapsed start.
to / fromDate?AbsentSupplies an absolute instant. Missing or invalid targets show --:--.
formatclock · unitsclockSelects a clock or localized duration units.
unitsdays · hours · minutes · secondsCountdown: all; elapsed: hours/minutes/secondsThe largest selected unit absorbs larger values.
announceoff · complete · minuteoffLimits polite announcements to completion or minute changes.
completeLabelStringTimer completeApplication-localized completion copy.
onCompleteOptional callbackAbsentReports one running-to-complete transition per target; an already-expired target is silent.

Native behavior

Design and accessibility

When to use it

Keep the target instant in host state. Backgrounding pauses updates while absolute time continues. Invalid targets show a placeholder; countdowns stop at zero and report completion once after running. The timer uses no animation.

Accessibility

One named timer exposes its current value. Ticking digits are not a live region; opt into polite completion or minute announcements.

Shared component

Available on other platforms

React NativeAndroid / Compose Web
Apple docsSwiftUI package