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

Stats Header

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

A title above a row of three stat tiles.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

HeaderStats.swift
// Stats Header · syxUI · https://syxui.dev/components/hdr-stats
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Title with a row of 3 stats
struct HeaderStats: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            Text("Dashboard").font(.system(size: 24, weight: .bold))
            HStack(spacing: 10) {
                ForEach([("2,840", "Views"), ("184", "Likes"), ("32", "Shares")], id: \.0) { v, l in
                    VStack(alignment: .leading, spacing: 3) {
                        Text(v).font(.system(size: 18, weight: .bold))
                        Text(l).font(.system(size: 12)).foregroundStyle(.secondary)
                    }.frame(maxWidth: .infinity, alignment: .leading).padding(12).background(Color.primary.opacity(0.05), in: RoundedRectangle(cornerRadius: 12))
                }
            }
        }.frame(width: 350)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17