---
title: "init(_:selection:displayedComponents:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/datepicker/init(_:selection:displayedcomponents:)"
---

# init(_:selection:displayedComponents:)

Creates an instance that selects a Date with an unbounded range.

## Declaration

```swift
nonisolated init(_ titleKey: LocalizedStringKey, selection: Binding<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date])
```

## Parameters

- `titleKey`: The key for the localized title of self, describing its purpose.
- `selection`: The date value being displayed and selected.
- `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.

## See Also

### Creating a date picker for any date

- [init(selection:displayedComponents:label:)](swiftui/datepicker/init(selection:displayedcomponents:label:).md)
