
Calendar Heatmap
From syxUI — written for both platforms, not translated between them.
A month calendar shaded by value.
Charts · SwiftUI · iOS 17
- charts
- swiftui
The actual source
CalendarHeatChart.swift
// Calendar Heatmap · syxUI · https://syxui.dev/components/chart2-calendar-heat
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let chPurple = Color(red: 0.55, green: 0.40, blue: 0.90)
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)
}
}
// Month calendar heatmap
struct CalendarHeatChart: View {
let vals: [Double] = (0..<30).map { Double(($0 * 37 + 11) % 100) / 100.0 }
var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack { Text("July").font(.system(size: 15, weight: .semibold)); Spacer(); Text("Focus minutes").font(.system(size: 12)).foregroundStyle(.secondary) }
LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 6), count: 7), spacing: 6) {
ForEach(Array(vals.enumerated()), id: \.offset) { _, v in
RoundedRectangle(cornerRadius: 5).fill(chPurple.opacity(0.15 + v * 0.75)).aspectRatio(1, contentMode: .fit)
}
}
}.formaCard().frame(width: 300)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


