<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/NSCollectionLayoutSupplementaryItem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionLayoutSupplementaryItem"
  },
  "title" : "NSCollectionLayoutSupplementaryItem"
}
-->

# NSCollectionLayoutSupplementaryItem

An object used to add an extra visual decoration to an item in a collection view.

```
@MainActor class NSCollectionLayoutSupplementaryItem
```

## Overview

You use supplementary items to attach additional views to your content. For example, you might attach a badge to an item or a frame around a group. A supplementary item follows the index path of the item it’s attached to.

If you want to create a header or footer for your layout or its sections, use a boundary supplementary item ([`NSCollectionLayoutBoundarySupplementaryItem`](/documentation/UIKit/NSCollectionLayoutBoundarySupplementaryItem)) instead.

Each type of supplementary item must have a unique element kind. Consider tracking these strings together in a way that makes it straightforward to identify each element, for example:

```swift
struct ElementKind {
    static let badge = "badge-element-kind"
    static let background = "background-element-kind"
    static let sectionHeader = "section-header-element-kind"
    static let sectionFooter = "section-footer-element-kind"
    static let layoutHeader = "layout-header-element-kind"
    static let layoutFooter = "layout-footer-element-kind"
}
```

Add supplementary items to an item by passing in an array of supplementary items when you construct the item:

```swift
let itemSize = NSCollectionLayoutSize(widthDimension: .absolute(44),
                                     heightDimension: .absolute(44))
    
let badgeAnchor = NSCollectionLayoutAnchor(edges: [.top, .trailing],
                                fractionalOffset: CGPoint(x: 0.3, y: -0.3))
   
let badgeSize = NSCollectionLayoutSize(widthDimension: .absolute(20),
                                      heightDimension: .absolute(20))
    
let badge = NSCollectionLayoutSupplementaryItem(layoutSize: badgeSize,
                                               elementKind: ElementKind.badge,
                                           containerAnchor: badgeAnchor)
    
let item = NSCollectionLayoutItem(layoutSize: itemSize,
                          supplementaryItems: [badge])
```

## Topics

### Creating a supplementary item

[`+  supplementaryItemWithLayoutSize:elementKind:containerAnchor:`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/init(layoutSize:elementKind:containerAnchor:))

Creates a supplementary item of the specified size and element kind, with an anchor relative to a container.

[`+  supplementaryItemWithLayoutSize:elementKind:containerAnchor:itemAnchor:`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/init(layoutSize:elementKind:containerAnchor:itemAnchor:))

Creates a supplementary item of the specified size and element kind, an anchor relative to a container, and an anchor relative to an item.

### Getting the anchors

[`itemAnchor`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/itemAnchor)

The anchor between the supplementary item and the item it’s attached to.

[`containerAnchor`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/containerAnchor)

The anchor between the supplementary item and the container it’s attached to.

### Getting the element kind

[`elementKind`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/elementKind)

A string that identifies the type of supplementary item.

### Specifying stacking order

[`zIndex`](/documentation/UIKit/NSCollectionLayoutSupplementaryItem/zIndex)

The vertical stacking order of the supplementary item in relation to other items in the section.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCopying`](/documentation/Foundation/NSCopying)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

### Inherits From

[`NSCollectionLayoutItem`](/documentation/UIKit/NSCollectionLayoutItem)

### Inherited By

[`NSCollectionLayoutBoundarySupplementaryItem`](/documentation/UIKit/NSCollectionLayoutBoundarySupplementaryItem)

---

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)