GlassTimeline
| Identifier | glass-timeline |
| Module | SPGlassData |
| Kind | content-component — plain content, no surface and no glass |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Data/GlassTimelineExample.swift |
Minimal usage
swift
ScrollView {
GlassTimeline(events)
}swift
let events = [
GlassTimelineEvent(id: "ordered", date: orderedAt, title: "Order placed"),
GlassTimelineEvent(id: "shipped", date: shippedAt, title: "Handed to the carrier", systemImage: "shippingbox"),
]Variants
| Variant | Use |
|---|---|
order: .ascending |
Oldest first (default): a history read from the beginning. |
order: .descending |
Most recent first: an activity feed. |
Event with systemImage |
The marker is the SF Symbol instead of a dot. |
Event with detail |
A second line under the title. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
events |
[GlassTimelineEvent] |
— | Events in any order. |
order |
GlassTimelineOrder |
.ascending |
Chronological direction. |
emptyTitle |
LocalizedStringKey? |
nil |
Text of the empty state; defaults to the localised "No events". |
GlassTimelineEvent(id:date:title:detail:systemImage:) — title and detail are data and displayed as they are.
Calendar, time zone and locale come from the environment (\.calendar, \.timeZone, \.locale).
States
- Empty: a
ContentUnavailableViewwithemptyTitle. - Populated: one header per calendar day (complete localised date) followed by that day's events with their time.
Advanced example
swift
GlassTimeline(log, order: .descending, emptyTitle: "Nothing has happened yet")
.environment(\.timeZone, TimeZone(identifier: "Asia/Tokyo") ?? .gmt)
.environment(\.locale, Locale(identifier: "fr_CA"))
// Grouping is a pure function, usable for exports or tests:
var calendar = Calendar(identifier: .gregorian)
calendar.timeZone = TimeZone(identifier: "America/Toronto") ?? .gmt
let days = GlassTimelineLogic.groups(log, order: .ascending, calendar: calendar)
let title = GlassTimelineLogic.dayTitle(days[0].day, calendar: calendar, locale: Locale(identifier: "fr_CA"))Accessibility
- Day titles are headers, so VoiceOver users can jump from day to day with the rotor.
- Each event is one element reading its time, title and detail.
- Markers and the connecting line are decorative and hidden from assistive technologies.
- Dates and times are formatted with
Date.FormatStylein the environment's locale, calendar and time zone; text follows Dynamic Type and wraps. - Layout uses leading and trailing only, so it mirrors in right-to-left languages.
Limits
- The day of an event depends on the time zone: the same instant can appear under different days for two users. This is intended; pass the time zone you want through the environment.
- Days of 23 or 25 hours (daylight saving time) are single groups; grouping relies on
Calendar.startOfDay(for:). - Events with the same date keep the order of the input array.
- Events are sorted and grouped in
bodyon every update; for very long logs paginate in the model. - The timeline has no scroll view of its own and no interaction (no selection, no expansion).
- Events are a fixed value type; a timeline with custom rows should use
GlassTimelineLogicwith its own views.