TechnologiesSwiftUI

DefaultDatePickerStyle struct

iOSmacOStvOSwatchOSvisionOS✓ renders

The default style for date pickers.

How it works

DefaultDatePickerStyle is the date-picker style SwiftUI applies when you don't request a specific one — the system's standard presentation for choosing a date and time. Rather than committing every DatePicker to a fixed appearance, it defers to the conventions of the current platform and context, so a picker reads as native on iOS, macOS, watchOS, and beyond. Reach for it when you want the ordinary, platform-appropriate control, or when you need to explicitly reset a picker back to the system default after another style was applied higher in the view hierarchy.

  1. Start from a DatePicker bound to a Date

    A date-picker style only has meaning when attached to a DatePicker, which needs a label and a binding to the value it edits. Here the picker is titled "Event Date" and writes through selection: $date to the @State private var date = Date(), giving the style a live value to present and update.

  2. Apply the style with datePickerStyle(_:)

    The datePickerStyle(_:) modifier sets the style for the DatePicker it's attached to — and for any pickers nested below it. Passing DefaultDatePickerStyle() selects the system's standard presentation, exactly as if no style had been specified at all.

  3. Construct the style with its no-argument initializer

    DefaultDatePickerStyle() takes no parameters because there's nothing to configure — the style intentionally carries no appearance options of its own, delegating all layout and interaction decisions to the platform. You instantiate it purely to name the system default in the datePickerStyle(DefaultDatePickerStyle()) call.

  4. Use it to override an inherited style

    Because datePickerStyle(_:) propagates down the hierarchy, a child picker can inherit a style set by an ancestor. Applying DefaultDatePickerStyle() on that child restores the standard look locally, making it the explicit way to opt back in to the system presentation.

Try it — Swap DefaultDatePickerStyle() for .compact (or .wheel) in the datePickerStyle(...) call to see how the same "Event Date" picker changes shape, then switch back to confirm DefaultDatePickerStyle matches the platform's standard presentation.

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.

DefaultDatePickerStyle.swift
struct DefaultDatePickerStyleDemo: View {
    @State private var date = Date()

    var body: some View {
        DatePicker("Event Date", selection: $date)
            .datePickerStyle(DefaultDatePickerStyle())
            .padding()
    }
}
Live preview
Event Date April 1, 2026
Event Date April 1, 2026
swift → lexer → parser → sema → uiir → canvas Open in Studio ↗
What's new in SwiftUI 27 →