<!--
{
  "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/NSCollectionLayoutDecorationItem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSCollectionLayoutDecorationItem"
  },
  "title" : "NSCollectionLayoutDecorationItem"
}
-->

# NSCollectionLayoutDecorationItem

An object used to add a background to a section of a collection view.

```
@MainActor class NSCollectionLayoutDecorationItem
```

## Overview

Each type of decoration 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 a background to a section by setting that section’s [`decorationItems`](/documentation/UIKit/NSCollectionLayoutSection/decorationItems) property:

```swift
let sectionBackground = NSCollectionLayoutDecorationItem.background(
        elementKind: ElementKind.background)

section.decorationItems = [sectionBackground]

let layout = UICollectionViewCompositionalLayout(section: section)
layout.register(
    SectionBackgroundDecorationView.self,
    forDecorationViewOfKind: ElementKind.background)
return layout
```

## Topics

### Creating a background

[`+  backgroundDecorationItemWithElementKind:`](/documentation/UIKit/NSCollectionLayoutDecorationItem/background(elementKind:))

Creates a section background with a string to identify the element kind.

### Getting the element kind

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

A string that identifies the type of decoration item.

### Specifying stacking order

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

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

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

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

### Inherits From

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

---

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)