TechnologiesSwiftUI

GraphicalDatePickerStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

A date picker style that displays an interactive calendar or clock.

How it works

GraphicalDatePickerStyle is a concrete DatePickerStyle that renders a DatePicker as a full interactive calendar surface — a month grid for choosing days and, where date and time components are shown together, wheel controls for the time. Reach for it when you want the date selection to be a prominent, browsable part of the screen rather than a compact field, such as a scheduling pane or a date-driven detail view. You don't instantiate the type directly; you apply it through the datePickerStyle(_:) modifier using the .graphical shorthand.

  1. Start from a bound DatePicker

    GraphicalDatePickerStyle only changes how an existing DatePicker is drawn, so you first need a picker bound to a date value. Here DatePicker("Event Date", selection: $date, displayedComponents: .date) reads and writes the @State private var date = Date() through the $date binding.

  2. Apply the style with .datePickerStyle(.graphical)

    The datePickerStyle(_:) modifier sets the presentation for the picker and any descendant pickers. Passing .graphical selects GraphicalDatePickerStyle, swapping the default compact field for the expanded calendar layout — that single .datePickerStyle(.graphical) call is what activates this symbol.

  3. Control what the calendar shows with displayedComponents

    The displayedComponents argument decides whether the graphical picker presents a calendar, time wheels, or both. Because this DatePicker passes displayedComponents: .date, the style renders just the month grid; including .hourAndMinute would add the time controls beneath it.

  4. Give the calendar room to lay out

    The graphical style needs more space than a compact field, so it expects to sit in a container that grants it room. The trailing .padding() insets the calendar from the surrounding view, which is where GraphicalDatePickerStyle plugs into the layout.

Try it — Change displayedComponents: .date to displayedComponents: [.date, .hourAndMinute] to see GraphicalDatePickerStyle add time wheels below the calendar grid.

Example & preview

Press Run live & edit to compile it in your browser — then edit the Swift on the left and the preview re-renders live.

GraphicalDatePickerStyle.swift
struct GraphicalDatePickerStyleDemo: View {
    @State private var date = Date()

    var body: some View {
        DatePicker("Event Date", selection: $date, displayedComponents: .date)
            .datePickerStyle(.graphical)
            .padding()
    }
}
Live preview
April 2026 SUN MON TUE WED THU FRI SAT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
April 2026 SUN MON TUE WED THU FRI SAT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →