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

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

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

## Declaration

```swift
nonisolated init(selection: Binding<Date>, in range: ClosedRange<Date>, displayedComponents: DatePicker<Label>.Components = [.hourAndMinute, .date], @ContentBuilder label: () -> Label)
```

## Parameters

- `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.
- `label`: A view that describes the use of the date.

## See Also

### Creating a date picker for specific dates

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