
Stat Card
From syxUI — written for both platforms, not translated between them.
A metric card with a value, trend chip and a mini bar chart.
Cards · SwiftUI · iOS 17
- cards
- swiftui
The actual source
StatCard.swift
// Stat Card · syxUI · https://syxui.dev/components/card-stat
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
extension View {
func formaCard(_ pad: CGFloat = 18) -> some View {
self.padding(pad)
.background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
.overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
.shadow(color: .black.opacity(0.05), radius: 14, x: 0, y: 6)
}
}
// Stat card - value + trend + mini bars
struct StatCard: View {
let green = Color(red: 0.16, green: 0.66, blue: 0.40)
var body: some View {
VStack(alignment: .leading, spacing: 10) {
HStack {
Text("Revenue").font(.system(size: 14)).foregroundStyle(.secondary)
Spacer()
HStack(spacing: 2) {
Image(systemName: "arrow.up.right").font(.system(size: 10, weight: .bold))
Text("12%").font(.system(size: 12, weight: .semibold))
}.foregroundStyle(green).padding(.horizontal, 7).padding(.vertical, 3).background(green.opacity(0.12), in: Capsule())
}
Text("$48,290").font(.system(size: 28, weight: .bold))
HStack(alignment: .bottom, spacing: 5) {
ForEach(0..<7, id: \.self) { i in
Capsule().fill(i == 6 ? green : green.opacity(0.2)).frame(height: [16.0,22,14,28,20,26,34].map { CGFloat($0) }[i])
}
}.frame(height: 34)
}.formaCard().frame(width: 240)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


