
Date Range
From syxUI — written for both platforms, not translated between them.
A single-month date range.
Inputs · SwiftUI · iOS 17
- inputs
- swiftui
The actual source
PickerRange.swift
// Date Range · syxUI · https://syxui.dev/components/picker-range
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let pkBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
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)
}
}
func weekdays() -> some View { HStack(spacing: 0) { ForEach(Array(["S", "M", "T", "W", "T", "F", "S"].enumerated()), id: \.offset) { _, d in Text(d).font(.system(size: 11, weight: .medium)).foregroundStyle(.secondary).frame(maxWidth: .infinity) } } }
func monthGrid(_ days: Int, _ lead: Int, _ selected: Set<Int>, _ accent: Color, range: Set<Int> = []) -> some View {
LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 7), spacing: 6) {
ForEach(Array(0..<lead), id: \.self) { _ in Color.clear.frame(height: 30) }
ForEach(1...days, id: \.self) { d in
Text("\(d)").font(.system(size: 13, weight: selected.contains(d) ? .bold : .regular)).foregroundStyle(selected.contains(d) ? .white : (range.contains(d) ? accent : .primary))
.frame(width: 30, height: 30)
.background { if selected.contains(d) { Circle().fill(accent) } else if range.contains(d) { Circle().fill(accent.opacity(0.14)) } }
}
}
}
struct PickerRange: View { var body: some View { VStack(spacing: 12) { HStack { Text("Jul 8 – Jul 14").font(.system(size: 16, weight: .semibold)); Spacer() }; weekdays(); monthGrid(31, 3, [8, 14], pkBlue, range: [9, 10, 11, 12, 13]) }.formaCard().frame(width: 320) } }
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


