<!--
{
  "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/OutlineGroup/init(_:children:content:)-2galq",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI12OutlineGroupVAA7Element_2IDQZRs_AA4ViewR0_q1_Rs0_AA010DisclosureD0Vyq0_AA0C16SubgroupChildrenVGRs2_s12IdentifiableADRpzrlE_8children7contentACyxq_q0_q0_ALGqd___s7KeyPathCyqd__xSgGq0_qd__ctcAEQyd__Rs_sAMRd__ANRsd__lufc"
  },
  "title" : "init(_:children:content:)"
}
-->

# init(_:children:content:)

Creates an outline group from a root data element and a key path to
its children.

```
init<DataElement>(_ root: DataElement, children: KeyPath<DataElement, Data?>, @ContentBuilder content: @escaping (DataElement) -> Leaf) where ID == DataElement.ID, DataElement : Identifiable, DataElement == Data.Element
```

## Parameters

`root`

The root of a collection of tree-structured, identified
data.

`children`

A key path to a property whose non-`nil` value gives the
children of a data element. 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 the
data element as a leaf in the tree, like a regular file in a file
system.

`content`

A content builder that produces a content view based on a
data element.

## Discussion

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

All generated disclosure groups begin in the collapsed state.

Make sure that the identifier of a data element only changes if you
mean to replace that element with a new element, one with a new
identity. If the ID of an element changes, then the content view
generated from that element will lose any current state and animations.

---

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)