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.
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 throughselection: $dateto the@State private var date = Date(), giving the style a live value to present and update.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. PassingDefaultDatePickerStyle()selects the system's standard presentation, exactly as if no style had been specified at all.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 thedatePickerStyle(DefaultDatePickerStyle())call.Use it to override an inherited style
Because
datePickerStyle(_:)propagates down the hierarchy, a child picker can inherit a style set by an ancestor. ApplyingDefaultDatePickerStyle()on that child restores the standard look locally, making it the explicit way to opt back in to the system presentation.
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.
struct DefaultDatePickerStyleDemo: View {
@State private var date = Date()
var body: some View {
DatePicker("Event Date", selection: $date)
.datePickerStyle(DefaultDatePickerStyle())
.padding()
}
}