<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/DatePicker/init(_:selection:in:displayedComponents:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10DatePickerVA2A4TextVRszrlE_9selection2in19displayedComponentsACyAEG10Foundation23LocalizedStringResourceV_AA7BindingVyAJ0C0VGSNyAPGAA0cdI0Vtcfc::OverloadGroup"
  },
  "title" : "init(_:selection:in:displayedComponents:)"
}
-->

# init(_:selection:in:displayedComponents:)

Creates an instance that selects a `Date` in a closed range.

```
@export(implementation) nonisolated init(_ titleResource: LocalizedStringResource, selection: Binding<Date>, in range: ClosedRange<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
```

## Parameters

`titleResource`

The localized title of `self`, describing
its purpose.

`selection`

The date value being displayed and selected.

`range`

The inclusive range of selectable dates.

`displayedComponents`

The date components that user is able to
view and edit. Defaults to `[.hourAndMinute, .date]`. On watchOS,
if `.hourAndMinute` or `.hourMinuteAndSecond` are included with
`.date`, only `.date` is displayed.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)