<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/OutlineGroup/init(_:children:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12OutlineGroupVAA7Element_2IDQZRs_AA15TableRowContentR0_q1_Rs0_q2_Rs1_0gH5ValueQy0_ADRtzrlE_8childrenACyxq_AA0gH0Vyqd__GA2NGx_s7KeyPathCyqd__xSgGtcAEQyd__Rs_ANRs0_ANRs1_ANRs2_s12IdentifiableRd__AJRsd__lufc::OverloadGroup"
  },
  "title" : "init(_:children:)"
}
-->

# init(_:children:)

Creates an outline group from a collection of root data elements and
a key path to element’s children.

```
init<DataElement>(_ data: Data, children: KeyPath<DataElement, Data?>) where ID == DataElement.ID, Parent == TableRow<DataElement>, Leaf == TableRow<DataElement>, Subgroup == TableRow<DataElement>, DataElement : Identifiable, DataElement == Data.Element
```

## Parameters

`data`

A collection of tree-structured, identified data.

`children`

A key path to a property whose non-`nil` value gives the
children of `data`. A non-`nil` but empty value denotes an element
capable of having children that’s 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 the outline group treats `data` as a
leaf in the tree, like a regular file in a file system.

## Discussion

This initializer provides a default `TableRowBuilder` using `TableRow`
for each data element.

This initializer creates an instance that uniquely identifies table rows
across updates based on the identity of the underlying data element.

All generated disclosure groups begin in the collapsed state.

---

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)