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

# NSCollectionLayoutDimension

An individual dimension representing an item’s width or height in a collection view.

```
@MainActor class NSCollectionLayoutDimension
```

## Overview

Each item in a collection view has an explicit width dimension and height dimension, which combine to define the item’s size ([`NSCollectionLayoutSize`](/documentation/AppKit/NSCollectionLayoutSize)).

You can express an item’s dimensions using an absolute, estimated, or fractional value.

Use an *absolute value* to specify exact dimensions, like a 44 x 44 point square:

```swift
let absoluteSize = NSCollectionLayoutSize(widthDimension: .absolute(44),
                                         heightDimension: .absolute(44))
```

Use an *estimated value* if the size of your content might change at runtime, such as when data is loaded or in response to a change in system font size. You provide an initial estimated size and the system computes the actual value later.

```swift
let estimatedSize = NSCollectionLayoutSize(widthDimension: .estimated(200),
                                          heightDimension: .estimated(100))
```

Use a *fractional value* to define a value that’s relative to a dimension of the item’s container. This option simplifies specifying aspect ratios. For example, the following item has a width and a height that are both equal to 20% of its container’s width, creating a square that grows and shrinks as the size of its container changes.

```swift
let fractionalSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.2),
                                           heightDimension: .fractionalWidth(0.2))
```

## Topics

### Creating a dimension

[`+  absoluteDimension:`](/documentation/AppKit/NSCollectionLayoutDimension/absolute(_:))

Creates a dimension with an absolute point value.

[`+  estimatedDimension:`](/documentation/AppKit/NSCollectionLayoutDimension/estimated(_:))

Creates a dimension with an estimated point value.

[`+  fractionalHeightDimension:`](/documentation/AppKit/NSCollectionLayoutDimension/fractionalHeight(_:))

Creates a dimension that is computed as a fraction of the height of the containing group.

[`+  fractionalWidthDimension:`](/documentation/AppKit/NSCollectionLayoutDimension/fractionalWidth(_:))

Creates a dimension that is computed as a fraction of the width of the containing group.

### Getting the dimension value

[`dimension`](/documentation/AppKit/NSCollectionLayoutDimension/dimension)

The floating-point value of the dimension.

### Getting the dimension type

[`isAbsolute`](/documentation/AppKit/NSCollectionLayoutDimension/isAbsolute)

A Boolean value that indicates whether the dimension is expressed as an absolute value.

[`isEstimated`](/documentation/AppKit/NSCollectionLayoutDimension/isEstimated)

A Boolean value that indicates whether the dimension is expressed as an estimated value.

[`isFractionalHeight`](/documentation/AppKit/NSCollectionLayoutDimension/isFractionalHeight)

A Boolean value that indicates whether the dimension is expressed as a fraction of its container’s height.

[`isFractionalWidth`](/documentation/AppKit/NSCollectionLayoutDimension/isFractionalWidth)

A Boolean value that indicates whether the dimension is expressed as a fraction of its container’s width.

## Relationships

### Conforms To

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

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

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

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

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

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

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

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

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)