Skip to content
Mini Calendar preview
Rendered from the SwiftUI source on this page.

Mini Calendar

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

A month calendar grid with a selected day.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

MiniCalendarCard.swift
// Mini Calendar · syxUI · https://syxui.dev/components/sel-calendar
// 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)
    }
}

// Mini month calendar
struct MiniCalendarCard: View {
    @State private var sel = 15
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    var body: some View {
        VStack(spacing: 12) {
            HStack {
                Text("July 2026").font(.system(size: 15, weight: .semibold))
                Spacer()
                Image(systemName: "chevron.left").font(.system(size: 13, weight: .semibold)).foregroundStyle(.secondary)
                Image(systemName: "chevron.right").font(.system(size: 13, weight: .semibold)).foregroundStyle(.secondary).padding(.leading, 16)
            }
            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)
                }
            }
            LazyVGrid(columns: Array(repeating: GridItem(.flexible()), count: 7), spacing: 8) {
                ForEach(0..<3, id: \.self) { _ in Color.clear.frame(height: 30) }
                ForEach(1...31, id: \.self) { day in
                    let on = sel == day
                    Text("\(day)").font(.system(size: 13, weight: on ? .bold : .regular)).foregroundStyle(on ? .white : .primary)
                        .frame(width: 30, height: 30)
                        .background(on ? blue : .clear, in: Circle())
                        .onTapGesture { sel = day }
                }
            }
        }.formaCard().frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17