Skip to content
Progress Table preview
Rendered from the SwiftUI source on this page.

Progress Table

From syxUI — written for both platforms, not translated between them.

Rows with an inline progress bar and percent complete.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableProgress.swift
// Progress Table · syxUI · https://syxui.dev/components/table-progress
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let tblGreen = Color(red: 0.13, green: 0.62, blue: 0.32)

let tblBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

extension View {
    func tblCard(_ w: CGFloat) -> some View {
        self.frame(width: w)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
            .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 18, style: .continuous).stroke(Color.primary.opacity(0.08), lineWidth: 1))
            .shadow(color: .black.opacity(0.04), radius: 10, x: 0, y: 4)
    }
}

/// Rows with an inline progress bar and percent (complete rows go green).
struct TableProgress: View {
    let rows: [(String, Double)] = [("Frontend", 0.92), ("Backend", 0.68), ("Design", 1.0), ("QA", 0.34)]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) {
                    Text(r.0).font(.system(size: 14, weight: .medium)).frame(width: 84, alignment: .leading)
                    GeometryReader { g in
                        ZStack(alignment: .leading) {
                            Capsule().fill(Color.primary.opacity(0.08)).frame(height: 6)
                            Capsule().fill(r.1 >= 1.0 ? tblGreen : tblBlue).frame(width: g.size.width * r.1, height: 6)
                        }.frame(maxHeight: .infinity, alignment: .center)
                    }.frame(height: 20)
                    Text("\(Int(r.1 * 100))%").font(.system(size: 12, weight: .semibold).monospacedDigit()).foregroundStyle(.secondary).frame(width: 38, alignment: .trailing)
                }
                .padding(.horizontal, 16).padding(.vertical, 10)
                if i < rows.count - 1 { Divider().padding(.leading, 16) }
            }
        }
        .tblCard(330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17