<!--
{
  "availability" : [
    "macOS: 10.15.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSCollectionViewCompositionalLayout",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionViewCompositionalLayout"
  },
  "title" : "NSCollectionViewCompositionalLayout"
}
-->

# NSCollectionViewCompositionalLayout

A layout object that lets you combine items in highly adaptive and flexible visual arrangements.

```
class NSCollectionViewCompositionalLayout
```

## Overview

A compositional layout is a type of collection view layout. It’s designed to be composable, flexible, and fast, letting you build any kind of visual arrangement for your content by combining—or compositing—each smaller component into a full layout.

A compositional layout is composed of one or more sections that break up the layout into distinct visual groupings. Each section is composed of groups of individual items, the smallest unit of data you want to present. A group might lay out its items in a horizontal row, a vertical column, or a custom arrangement.

You combine the components by building up from items into a group, from groups into a section, and finally into a full layout, like in this example of a basic list layout:

```swift
func createBasicListLayout() -> NSCollectionViewLayout {
    let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
                                         heightDimension: .fractionalHeight(1.0))
    let item = NSCollectionLayoutItem(layoutSize: itemSize)
  
    let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0),
                                          heightDimension: .absolute(44))
    let group = NSCollectionLayoutGroup.horizontal(layoutSize: groupSize,
                                                     subitems: [item])
  
    let section = NSCollectionLayoutSection(group: group)

    let layout = NSCollectionViewCompositionalLayout(section: section)
    return layout
}
```

## Topics

### Creating a Layout

[`init(section:)`](/documentation/AppKit/NSCollectionViewCompositionalLayout/init(section:))

Creates a compositional layout object with a single section.

[`init(section:configuration:)`](/documentation/AppKit/NSCollectionViewCompositionalLayout/init(section:configuration:))

Creates a compositional layout object with a single section and an additional configuration.

[`init(sectionProvider:)`](/documentation/AppKit/NSCollectionViewCompositionalLayout/init(sectionProvider:))

Creates a compositional layout object with a section provider to supply the layout’s sections.

[`init(sectionProvider:configuration:)`](/documentation/AppKit/NSCollectionViewCompositionalLayout/init(sectionProvider:configuration:))

Creates a compositional layout object with a section provider and an additional configuration.

### Configuring the Layout

[`configuration`](/documentation/AppKit/NSCollectionViewCompositionalLayout/configuration)

The layout’s configuration, such as its scroll direction and section spacing.



---

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)