<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOutlineView/collapseItem(_:collapseChildren:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOutlineView(im)collapseItem:collapseChildren:"
  },
  "title" : "collapseItem(_:collapseChildren:)"
}
-->

# collapseItem(_:collapseChildren:)

Collapses a given item and, optionally, its children.

```
func collapseItem(_ item: Any?, collapseChildren: Bool)
```

## Parameters

`item`

An item in the receiver.

    Starting in OS X version 10.5,  passing     `'nil'`     will collapse each item under the root in the outline view.

`collapseChildren`

If <doc://com.apple.documentation/documentation/Swift/true>, recursively collapses `item` and its children. If <doc://com.apple.documentation/documentation/Swift/false>, collapses `item` only (identical to [`collapseItem(_:)`](/documentation/AppKit/NSOutlineView/collapseItem(_:))).

## Discussion

For example, this method is invoked with the `collapseChildren` parameter set to <doc://com.apple.documentation/documentation/Swift/true> when a user Option-clicks the disclosure triangle for an item in the outline view (to collapse the item and all its contained items).

For each item collapsed, posts an item collapsed notification.

---

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)