<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/List/init(_:children:selection:rowContent:)-2pt7r",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ListV_8children9selection10rowContentACyxAA12OutlineGroupVyqd__7Element_2IDQYd__qd_0_qd_0_AA010DisclosureI0Vyqd_0_AA0H16SubgroupChildrenVGGGqd___s7KeyPathCyAIQyd__qd__SgGAA7BindingVyxSgGSgqd_0_AUctcAQRs_SkRd__AA4ViewRd_0_s12IdentifiableAURQr0_lufc"
  },
  "title" : "init(_:children:selection:rowContent:)"
}
-->

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

Creates a hierarchical list that computes its rows on demand from an
underlying collection of identifiable data, optionally allowing users to
select a single row.

```
nonisolated init<Data, RowContent>(_ data: Data, children: KeyPath<Data.Element, Data?>, selection: Binding<SelectionValue?>?, @ContentBuilder rowContent: @escaping (Data.Element) -> RowContent) where Content == OutlineGroup<Data, Data.Element.ID, RowContent, RowContent, DisclosureGroup<RowContent, OutlineSubgroupChildren>>, 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 selected value.

`rowContent`

A content builder that creates the view for a single row of
the list.

---

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)