Skip to content
Mini Stats preview
Rendered from the SwiftUI source on this page.

Mini Stats

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

A compact two-column stat card.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableMini.swift
// Mini Stats · syxUI · https://syxui.dev/components/table-mini
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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)
    }
}

/// Compact two-column stat card (activity summary).
struct TableMini: View {
    let rows: [(String, String)] = [
        ("Distance", "5.2 km"), ("Pace", "5:12 /km"), ("Calories", "412"), ("Elev. gain", "84 m"),
    ]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack {
                    Text(r.0).font(.system(size: 13)).foregroundStyle(.secondary)
                    Spacer()
                    Text(r.1).font(.system(size: 14, weight: .semibold).monospacedDigit())
                }.padding(.vertical, 9)
                if i < rows.count - 1 { Divider() }
            }
        }
        .padding(.horizontal, 16).padding(.vertical, 6)
        .tblCard(240)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17