SwiftUI.cc
Snippets
ControlsDate & TimeIntermediate

SwiftUI MultiDatePicker for Selecting Multiple Dates

MultiDatePicker binds a Set of DateComponents and lets users toggle several days on a calendar grid — availability, shifts, and recurring plans.

3 min readUpdated 2026-06
Availability picker bounded to the near future
import SwiftUI

struct AvailabilityPicker: View {
    @State private var days: Set<DateComponents> = []

    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            MultiDatePicker("Available days", selection: $days,
                            in: Date.now...)
            Text("\(days.count) day(s) selected")
                .font(.footnote)
                .foregroundStyle(.secondary)
        }
        .padding()
    }
}

MultiDatePicker preview

A set, not a date

The binding type tells the story: Set<DateComponents>. Every tapped day inserts or removes its year-month-day components. Your model probably wants Date, so convert deliberately:

let dates = days.compactMap { Calendar.current.date(from: $0) }

Going the other way (pre-seeding selection from stored dates) uses Calendar.current.dateComponents([.calendar, .era, .year, .month, .day], from: date) — include the calendar and era so the components match what the picker produces.

Windowing

in: Date.now... or any range limits tappable days. Pair it with domain rules — a staffing app might bound to the schedule period and pre-select existing shifts.

What it does not do

No range dragging, no per-day metadata, no time selection. A booking flow that wants check-in/check-out should present two DatePickers or a custom calendar; MultiDatePicker models independent days, and stretching it past that reads awkwardly to users.

Common mistakes

  • Comparing Set against Dates without conversion.
  • Expecting ordered selection — sets are unordered; sort after converting.
  • Using it for ranges and forcing users to tap fourteen days one by one.

Related reference