Picks a date, a time, or both with SwiftUI's native date picker.
Usage
DatePicker already brings the calendar, keyboard and VoiceOver support, and the formats for every language and region, so use it directly:
By default, iOS shows the title on the leading side and the date in a compact field on the trailing side. Tapping the field opens a calendar. The field is as tall as FLX's text fields and pickers, so they line up in the same screen.
To hide the title, add .labelsHidden(). VoiceOver still reads it.
Examples
Date and time
displayedComponents picks what people can change: .date, .hourAndMinute, or both, which is the default.
Graphical
.graphical shows the calendar inline. Use it when picking the date is the main task of a screen, such as booking.
Wheel
.wheel shows scrolling wheels. It fits a time that people set often, such as an alarm.
Range
Pass a range to in: to limit the dates people can pick. Dates outside it appear dimmed in the calendar.
In a form
Inside a Form, each date picker becomes a row, with the title on the leading side.
With Form Field
Inside a Form Field, hide the date picker's title with .labelsHidden() and let FLXFieldLabel show it above, with a description below.
Color
The .graphical calendar uses the theme's tint, which .flxTheme applies at the root of your app, for today and the selected date. Without a tint, it uses the app's AccentColor.
The compact field and the wheels stay neutral and don't take the tint.
Text size
The compact field grows with Dynamic Type. At the largest accessibility sizes, a picker with a date and a time shows them on two lines.
.controlSize(_:) doesn't change the date picker on iOS.
For more information about date pickers, see the Apple documentation.











