---
title: "init(_:children:selection:rowContent:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/list/init(_:children:selection:rowcontent:)"
---

# init(_:children:selection:rowContent:)

Creates a hierarchical list that computes its rows on demand from a binding to an underlying collection of identifiable data and allowing users to have exactly one row always selected.

## Declaration

```swift
nonisolated init<Data, RowContent>(_ data: Binding<Data>, children: WritableKeyPath<Data.Element, Data?>, selection: Binding<SelectionValue>, @ContentBuilder rowContent: @escaping (Binding<Data.Element>) -> RowContent) where Content == OutlineGroup<Binding<Data>, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, Data : MutableCollection, Data : RandomAccessCollection, RowContent : View, Data.Element : Identifiable
```

## Parameters

- `data`: The identifiable data for computing the list.
- `children`: A key path to a property whose non-nil value gives the children of data. A non-nil but empty value denotes a node capable of having children that is currently childless, such as an empty directory in a file system. On the other hand, if the property at the key path is nil, then data is treated as a leaf node in the tree, like a regular file in a file system.
- `selection`: A binding to a non optional selected value.
- `rowContent`: A content builder that creates the view for a single row of the list.

## See Also

### Creating a list from hierarchical data

- [init(_:children:rowContent:)](swiftui/list/init(_:children:rowcontent:).md)
- [init(_:id:children:rowContent:)](swiftui/list/init(_:id:children:rowcontent:).md)
- [init(_:id:children:selection:rowContent:)](swiftui/list/init(_:id:children:selection:rowcontent:).md)
