Much like the rendered component itself, the initializer for SwiftUI’s DatePicker is overflowing with choices for potential method signatures:

Visually, it's a lot to take 🙂.

Regarding the picker's label, some of its initializers take it as a String in the first argument; some of them take a trailing ViewBuilder closure that generates a Text element; and in all cases, the label appears alongside the selection wheel when rendered in the UI:

Seems logical. But this can present a problem if your design calls for the label to reside above the picker — on its own line, and as its own element in your code.

Conveniently, though, DatePicker has a labelsHidden modifier that will prevent the default display behavior — while still availing itself of the provided label for accessibility support.

Combined with declaring a separate Text element above the picker, achieving the right design is actually pretty straightforward:


Composing a view with another modifier instead of foraging for the right initializer is one of the many cognitive shifts engendered by moving from UIKit to SwiftUI.

DatePicker, in particular, can be a bit imposing upon first use. But when it clicks, it clicks – true to its delightful sound.