Skip to content
Day Picker preview
Rendered from the SwiftUI source on this page.

Day Picker

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

A day-of-week repeat picker - tap the circles to toggle each day on or off.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

DayPickerCard.swift
// Day Picker · syxUI · https://syxui.dev/components/sel-day-picker
// 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)
    }
}

// Day-of-week repeat picker - multi-select circles (habit / booking apps)
struct DayPickerCard: View {
    @State private var active: Set<Int> = [1, 3, 5]
    let days = ["M", "T", "W", "T", "F", "S", "S"]
    let accent = Color(red: 0.0, green: 0.48, blue: 1.0)
    var body: some View {
        VStack(alignment: .leading, spacing: 14) {
            Text("Repeat").font(.system(size: 15, weight: .semibold))
            HStack(spacing: 0) {
                ForEach(Array(days.enumerated()), id: \.offset) { i, d in
                    let on = active.contains(i)
                    Text(d)
                        .font(.system(size: 14, weight: .semibold))
                        .foregroundStyle(on ? .white : Color.primary.opacity(0.55))
                        .frame(width: 38, height: 38)
                        .background(on ? accent : Color.primary.opacity(0.05), in: Circle())
                        .onTapGesture { withAnimation(.snappy) { if on { active.remove(i) } else { active.insert(i) } } }
                    if i < days.count - 1 { Spacer(minLength: 0) }
                }
            }
        }.formaCard()
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • formaCard

Requires iOS 17