<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/EnvironmentValues/horizontalSizeClass",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI17EnvironmentValuesV19horizontalSizeClassAA013UserInterfacefG0OSgvp"
  },
  "title" : "horizontalSizeClass"
}
-->

# horizontalSizeClass

The horizontal size class of this environment.

```
@backDeployed(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
var horizontalSizeClass: UserInterfaceSizeClass? { get set }
```

## Discussion

You receive a [`UserInterfaceSizeClass`](/documentation/SwiftUI/UserInterfaceSizeClass) value when you read this
environment value. The value tells you about the amount of horizontal
space available to the view that reads it. You can read this
size class like any other of the [`EnvironmentValues`](/documentation/SwiftUI/EnvironmentValues), by creating a
property with the [`Environment`](/documentation/SwiftUI/Environment) property wrapper:

```
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
```

SwiftUI sets this size class based on several factors, including:

- The current device type.
- The orientation of the device.
- The appearance of Slide Over and Split View on iPad.

Several built-in views change their behavior based on this size class.
For example, a [`NavigationView`](/documentation/SwiftUI/NavigationView) presents a multicolumn view when
the horizontal size class is [`UserInterfaceSizeClass.regular`](/documentation/SwiftUI/UserInterfaceSizeClass/regular),
but a single column otherwise. You can also adjust the appearance of
custom views by reading the size class and conditioning your views.
If you do, be prepared to handle size class changes while
your app runs, because factors like device orientation can change at
runtime.

In watchOS, the horizontal size class is always
[`UserInterfaceSizeClass.compact`](/documentation/SwiftUI/UserInterfaceSizeClass/compact). In macOS, and tvOS, it’s always
[`UserInterfaceSizeClass.regular`](/documentation/SwiftUI/UserInterfaceSizeClass/regular).

Writing to the horizontal size class in the environment
before macOS 14.0, tvOS 17.0, and watchOS 10.0 is not supported.

---

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)