SP GlassKit1.1.0

GlassTimeline

Dated events in order, grouped by day and localised, with an empty state.

  • Content
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-timeline

Content on an opaque, readable surface. Glass is kept for controls.

GlassTimeline running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-timeline

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-timeline
ModuleSPGlassData
Kindcontent-component — plain content, no surface and no glass
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/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

VariantUse
order: .ascendingOldest first (default): a history read from the beginning.
order: .descendingMost recent first: an activity feed.
Event with systemImageThe marker is the SF Symbol instead of a dot.
Event with detailA second line under the title.

Parameters

ParameterTypeDefaultMeaning
events[GlassTimelineEvent]—Events in any order.
orderGlassTimelineOrder.ascendingChronological direction.
emptyTitleLocalizedStringKey?nilText 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).

Layout and tone

ParameterTypeDefaultMeaning
GlassTimelineEvent.toneGlassBadgeTone.accentColour of the event's marker. Decorative: the title carries the meaning.

Each event shows its time in a leading column, a marker on a rail (a tinted tile holding the event's symbol, or a ring) and its title and detail. Day titles are uppercase eyebrow labels followed by a hairline. At accessibility text sizes the time moves above the title. The timeline has no surface of its own: place it in a GlassCard or on a page.

States

  • Empty: a ContentUnavailableView with emptyTitle.
  • 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.FormatStyle in 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 body on 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 GlassTimelineLogic with its own views.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassTimelineExample: GlassExample {
    public static let componentID = "glass-timeline"

    // Fictitious delivery log, relative to a fixed instant so that the example is reproducible.
    private static let events: [GlassTimelineEvent] = {
        let start = Date(timeIntervalSince1970: 1_780_300_800)
        func at(_ hours: Double) -> Date { start.addingTimeInterval(hours * 3600) }
        return [
            GlassTimelineEvent(id: "ordered", date: at(0), title: "Order placed", detail: "Order A-1042, three items", systemImage: "cart"),
            GlassTimelineEvent(id: "paid", date: at(0.2), title: "Payment confirmed"),
            GlassTimelineEvent(id: "packed", date: at(21), title: "Parcel packed", detail: "Warehouse 4, aisle 12 — a long note that wraps over several lines on a narrow screen without being cut off."),
            GlassTimelineEvent(id: "shipped", date: at(27.5), title: "Handed to the carrier", systemImage: "shippingbox"),
            GlassTimelineEvent(id: "transit", date: at(52), title: "In transit 🚚", detail: "مركز الفرز · Centre de tri"),
            GlassTimelineEvent(id: "delivered", date: at(76), title: "Delivered", systemImage: "checkmark", tone: .success),
        ]
    }()

    @State private var order = GlassTimelineOrder.descending
    @State private var showsEmpty = false

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(alignment: .leading, spacing: 16) {
                Picker("Order", selection: $order) {
                    Text("Newest first").tag(GlassTimelineOrder.descending)
                    Text("Oldest first").tag(GlassTimelineOrder.ascending)
                }
                .pickerStyle(.segmented)
                Toggle("Show the empty state", isOn: $showsEmpty)
                GlassTimeline(showsEmpty ? [] : Self.events, order: order, emptyTitle: "Nothing has happened yet")
            }
            .padding()
        }
    }
}

#Preview("GlassTimeline") { GlassTimelineExample() }
#Preview("GlassTimeline — français, Tokyo") {
    GlassTimelineExample()
        .environment(\.locale, Locale(identifier: "fr_CA"))
        .environment(\.timeZone, TimeZone(identifier: "Asia/Tokyo") ?? .gmt)
}

Registry entry

Identifierglass-timeline
Version1.1.0
Depends onglass-components-support, glass-foundation
FrameworksSwiftUI
Public symbolsGlassTimelineEvent, GlassTimelineOrder, GlassTimelineDay, GlassTimelineLogic, GlassTimeline
LicenceMIT
Manifestmanifest.json

Files