One Logo Pool Ball
SwiftUICore · IOS API REFERENCE

EnvironmentValues

struct · iOS 13.0+ · SDK 27.1

struct EnvironmentValues

A collection of environment values propagated through a view hierarchy. SwiftUI exposes a collection of values to your app's views in an `EnvironmentValues` structure. To read a value from the structure, declare a property using the ``Environment`` property wrapper and specify the value's key path. For example, you can read the current locale: @Environment(\.locale) var locale: Locale Use the property you declare to dynamically control a view's layout. SwiftUI automatically sets or updates many environment values, like ``EnvironmentValues/pixelLength``, ``EnvironmentValues/scenePhase``, or ``EnvironmentValues/locale``, based on device characteristics, system state, or user settings. For others, like ``EnvironmentValues/lineLimit``, SwiftUI provides a reasonable default value. You can set or override some values using the ``View/environment(_:_:)`` view modifier: MyView() .environment(\.lineLimit, 2) The value that you set affects the environment for the view that you modify --- including its descendants in the view hierarchy --- but only up to the point where you apply a different environment modifier. SwiftUI provides dedicated view modifiers for setting some values, which typically makes your code easier to read. For example, rather than setting the ``EnvironmentValues/lineLimit`` value directly, as in the previous example, you should instead use the ``View/lineLimit(_:)`` modifier: MyView() .lineLimit(2) In some cases, using a dedicated view modifier provides additional functionality. For example, you must use the ``View/preferredColorScheme(_:)`` modifier rather than setting ``EnvironmentValues/colorScheme`` directly to ensure that the new value propagates up to the presenting container when presenting a view like a popover: MyView() .popover(isPresented: $isPopped) { PopoverContent() .preferredColorScheme(.dark) } Create a custom environment value by declaring a new property in an extension to the environment values structure and applying the ``Entry()`` macro to the variable declaration: extension EnvironmentValues { @Entry var myCustomValue: String = "Default value" } extension View { func myCustomValue(_ myCustomValue: String) -> some View { environment(\.myCustomValue, myCustomValue) } } Clients of your value then access the value in the usual way, reading it with the ``Environment`` property wrapper, and setting it with the `myCustomValue` view modifier.

Members (108)

get · iOS 13.0+

imageScale

TypeScript
get imageScale(): Image_Scale
Swift declaration
var imageScale: Image.Scale { get set }

The image scale for this environment.

set · iOS 13.0+

imageScale

TypeScript
set imageScale(value: Image_Scale)
Swift declaration
var imageScale: Image.Scale { get set }

The image scale for this environment.

get · iOS 26.0+

lineHeight

TypeScript
get lineHeight(): (_CoreText_AttributedString_LineHeight) | null
Swift declaration
var lineHeight: AttributedString.LineHeight? { get set }

The default line height for text influenced by this environment. The default value is `nil`. In that case, SwiftUI automatically chooses an appropriate line height setting for each context.

set · iOS 26.0+

lineHeight

TypeScript
set lineHeight(value: (_CoreText_AttributedString_LineHeight) | null)
Swift declaration
var lineHeight: AttributedString.LineHeight? { get set }

The default line height for text influenced by this environment. The default value is `nil`. In that case, SwiftUI automatically chooses an appropriate line height setting for each context.

get · iOS 13.0+

colorScheme

TypeScript
get colorScheme(): ColorScheme
Swift declaration
var colorScheme: ColorScheme { get set }

The color scheme of this environment. Read this environment value from within a view to find out if SwiftUI is currently displaying the view using the ``ColorScheme/light`` or ``ColorScheme/dark`` appearance. The value that you receive depends on whether the user has enabled Dark Mode, possibly superseded by the configuration of the current presentation's view hierarchy. @Environment(\.colorScheme) private var colorScheme var body: some View { Text(colorScheme == .dark ? "Dark" : "Light") } You can set the `colorScheme` environment value directly, but that usually isn't what you want. Doing so changes the color scheme of the given view and its child views but *not* the views above it in the view hierarchy. Instead, set a color scheme using the ``View/preferredColorScheme(_:)`` modifier, which also propagates the value up through the view hierarchy to the enclosing presentation, like a sheet or a window. When adjusting your app's user interface to match the color scheme, consider also checking the ``EnvironmentValues/colorSchemeContrast`` property, which reflects a system-wide contrast setting that the user controls. For information, see <doc://com.apple.documentation/design/human-interface-guidelines/accessibility#Color-and-effects> in the Human Interface Guidelines. > Note: If you only need to provide different colors or images for different color scheme and contrast settings, do that in your app's Asset Catalog. See <doc://com.apple.documentation/documentation/Xcode/Asset-Management>.

set · iOS 13.0+

colorScheme

TypeScript
set colorScheme(value: ColorScheme)
Swift declaration
var colorScheme: ColorScheme { get set }

The color scheme of this environment. Read this environment value from within a view to find out if SwiftUI is currently displaying the view using the ``ColorScheme/light`` or ``ColorScheme/dark`` appearance. The value that you receive depends on whether the user has enabled Dark Mode, possibly superseded by the configuration of the current presentation's view hierarchy. @Environment(\.colorScheme) private var colorScheme var body: some View { Text(colorScheme == .dark ? "Dark" : "Light") } You can set the `colorScheme` environment value directly, but that usually isn't what you want. Doing so changes the color scheme of the given view and its child views but *not* the views above it in the view hierarchy. Instead, set a color scheme using the ``View/preferredColorScheme(_:)`` modifier, which also propagates the value up through the view hierarchy to the enclosing presentation, like a sheet or a window. When adjusting your app's user interface to match the color scheme, consider also checking the ``EnvironmentValues/colorSchemeContrast`` property, which reflects a system-wide contrast setting that the user controls. For information, see <doc://com.apple.documentation/design/human-interface-guidelines/accessibility#Color-and-effects> in the Human Interface Guidelines. > Note: If you only need to provide different colors or images for different color scheme and contrast settings, do that in your app's Asset Catalog. See <doc://com.apple.documentation/documentation/Xcode/Asset-Management>.

get · iOS 15.0+

controlSize

TypeScript
get controlSize(): ControlSize
Swift declaration
var controlSize: ControlSize { get set }

The size to apply to controls within a view. The default is ``ControlSize/regular``.

set · iOS 15.0+

controlSize

TypeScript
set controlSize(value: ControlSize)
Swift declaration
var controlSize: ControlSize { get set }

The size to apply to controls within a view. The default is ``ControlSize/regular``.

get · iOS 13.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A string that represents the contents of the environment values instance.

get · iOS 13.0+

lineSpacing

TypeScript
get lineSpacing(): number
Swift declaration
var lineSpacing: CGFloat { get set }

The distance in points between the bottom of one line fragment and the top of the next. This value is always nonnegative.

set · iOS 13.0+

lineSpacing

TypeScript
set lineSpacing(value: number)
Swift declaration
var lineSpacing: CGFloat { get set }

The distance in points between the bottom of one line fragment and the top of the next. This value is always nonnegative.

get · iOS 13.0+

pixelLength

TypeScript
get pixelLength(): number
Swift declaration
var pixelLength: CGFloat { get }

The size of a pixel on the screen. This value is usually equal to `1` divided by ``EnvironmentValues/displayScale``.

get · iOS 26.0+

buttonSizing

TypeScript
get buttonSizing(): ButtonSizing
Swift declaration
var buttonSizing: ButtonSizing { get }

The preferred sizing behavior of buttons in the view hierarchy. Views may use the specified button sizing when determining the size they choose to be in their primary axis within their parent view's proposed size. Use ``View/buttonSizing(_:)`` to set the preferred sizing behavior in the environment. Many built-in controls that display as a button adapt to this environment value. You can read the environment value in your own views and styles as well to adapt to the preferred sizing. struct CustomButtonStyle: ButtonStyle { @Environment(\.buttonSizing) private var buttonSizing private var maxWidth: CGFloat { switch buttonSizing { case .flexible: .infinity case .fitted, _: nil } } func makeBody(configuration: Configuration) -> some View { configuration.content .frame(maxWidth: maxWidth) .background(.tint, in: Capsule()) } }

get · iOS 13.0+

displayScale

TypeScript
get displayScale(): number
Swift declaration
var displayScale: CGFloat { get set }

The display scale of this environment.

set · iOS 13.0+

displayScale

TypeScript
set displayScale(value: number)
Swift declaration
var displayScale: CGFloat { get set }

The display scale of this environment.

get · iOS 13.0+ · Deprecated in iOS 100000.0

sizeCategory

TypeScript
get sizeCategory(): ContentSizeCategory
Swift declaration
var sizeCategory: ContentSizeCategory { get set }

The preferred size of the content. The default value is ``ContentSizeCategory/large``.

set · iOS 13.0+ · Deprecated in iOS 100000.0

sizeCategory

TypeScript
set sizeCategory(value: ContentSizeCategory)
Swift declaration
var sizeCategory: ContentSizeCategory { get set }

The preferred size of the content. The default value is ``ContentSizeCategory/large``.

get · iOS 18.0+

appearsActive

TypeScript
get appearsActive(): boolean
Swift declaration
@backDeployed(before: macOS 15.0)
var appearsActive: Bool { get set }

Whether views and styles in this environment should prefer an active appearance over an inactive appearance. On macOS, views in the focused window (also referred to as the "key" window) should appear active. Some contexts also appear active in other circumstances, such as the contents of a window toolbar appearing active when the window is not focused but is the main window. Typical adjustments made when a view does not appear active include: - Uses of `Color.accentColor` should generally be removed or replaced with a desaturated style. - Text and image content in sidebars should appear dimmer. - Buttons with destructive actions should appear disabled. - `ShapeStyle.selection` and selection in list and tables will automatically become a grey color Custom views, styles, and shape styles can use this to adjust their own appearance: struct ProminentPillButtonStyle: ButtonStyle { @Environment(\.appearsActive) private var appearsActive func makeBody(configuration: Configuration) -> some View { configuration.label .lineLimit(1) .padding(.horizontal, 8) .padding(.vertical, 2) .frame(minHeight: 20) .overlay(Capsule().strokeBorder(.tertiary)) .background(appearsActive ? Color.accentColor : .clear, in: .capsule) .contentShape(.capsule) } } On all other platforms, this value is always `true`. This is bridged with `UITraitCollection.activeAppearance` for UIKit hosted content.

set · iOS 18.0+

appearsActive

TypeScript
set appearsActive(value: boolean)
Swift declaration
@backDeployed(before: macOS 15.0)
var appearsActive: Bool { get set }

Whether views and styles in this environment should prefer an active appearance over an inactive appearance. On macOS, views in the focused window (also referred to as the "key" window) should appear active. Some contexts also appear active in other circumstances, such as the contents of a window toolbar appearing active when the window is not focused but is the main window. Typical adjustments made when a view does not appear active include: - Uses of `Color.accentColor` should generally be removed or replaced with a desaturated style. - Text and image content in sidebars should appear dimmer. - Buttons with destructive actions should appear disabled. - `ShapeStyle.selection` and selection in list and tables will automatically become a grey color Custom views, styles, and shape styles can use this to adjust their own appearance: struct ProminentPillButtonStyle: ButtonStyle { @Environment(\.appearsActive) private var appearsActive func makeBody(configuration: Configuration) -> some View { configuration.label .lineLimit(1) .padding(.horizontal, 8) .padding(.vertical, 2) .frame(minHeight: 20) .overlay(Capsule().strokeBorder(.tertiary)) .background(appearsActive ? Color.accentColor : .clear, in: .capsule) .contentShape(.capsule) } } On all other platforms, this value is always `true`. This is bridged with `UITraitCollection.activeAppearance` for UIKit hosted content.

get · iOS 15.0+

symbolVariants

TypeScript
get symbolVariants(): SymbolVariants
Swift declaration
var symbolVariants: SymbolVariants { get set }

The symbol variant to use in this environment. You set this environment value indirectly by using the ``View/symbolVariant(_:)`` view modifier. However, you access the environment variable directly using the ``View/environment(_:_:)`` modifier. Do this when you want to use the ``SymbolVariants/none`` variant to ignore the value that's already in the environment: HStack { Image(systemName: "heart") Image(systemName: "heart") .environment(\.symbolVariants, .none) } .symbolVariant(.fill) ![A screenshot of two heart symbols. The first is filled while the second is outlined.](SymbolVariants-none-1)

set · iOS 15.0+

symbolVariants

TypeScript
set symbolVariants(value: SymbolVariants)
Swift declaration
var symbolVariants: SymbolVariants { get set }

The symbol variant to use in this environment. You set this environment value indirectly by using the ``View/symbolVariant(_:)`` view modifier. However, you access the environment variable directly using the ``View/environment(_:_:)`` modifier. Do this when you want to use the ``SymbolVariants/none`` variant to ignore the value that's already in the environment: HStack { Image(systemName: "heart") Image(systemName: "heart") .environment(\.symbolVariants, .none) } .symbolVariant(.fill) ![A screenshot of two heart symbols. The first is filled while the second is outlined.](SymbolVariants-none-1)

get · iOS 13.0+

truncationMode

TypeScript
get truncationMode(): Text_TruncationMode
Swift declaration
var truncationMode: Text.TruncationMode { get set }

A value that indicates how the layout truncates the last line of text to fit into the available space. The default value is ``Text/TruncationMode/tail``. Some controls, however, might have a different default if appropriate.

set · iOS 13.0+

truncationMode

TypeScript
set truncationMode(value: Text_TruncationMode)
Swift declaration
var truncationMode: Text.TruncationMode { get set }

A value that indicates how the layout truncates the last line of text to fit into the available space. The default value is ``Text/TruncationMode/tail``. Some controls, however, might have a different default if appropriate.

get · iOS 16.0+

backgroundStyle

TypeScript
get backgroundStyle(): (AnyShapeStyle) | null
Swift declaration
var backgroundStyle: AnyShapeStyle? { get set }

An optional style that overrides the default system background style when set.

set · iOS 16.0+

backgroundStyle

TypeScript
set backgroundStyle(value: (AnyShapeStyle) | null)
Swift declaration
var backgroundStyle: AnyShapeStyle? { get set }

An optional style that overrides the default system background style when set.

get · iOS 15.0+

dynamicTypeSize

TypeScript
get dynamicTypeSize(): DynamicTypeSize
Swift declaration
var dynamicTypeSize: DynamicTypeSize { get set }

The current Dynamic Type size. This value changes as the user's chosen Dynamic Type size changes. The default value is device-dependent. When limiting the Dynamic Type size, consider if adding a large content view with ``View/accessibilityShowsLargeContentViewer()`` would be appropriate. On macOS, this value cannot be changed by users and does not affect the text size.

set · iOS 15.0+

dynamicTypeSize

TypeScript
set dynamicTypeSize(value: DynamicTypeSize)
Swift declaration
var dynamicTypeSize: DynamicTypeSize { get set }

The current Dynamic Type size. This value changes as the user's chosen Dynamic Type size changes. The default value is device-dependent. When limiting the Dynamic Type size, consider if adding a large content view with ``View/accessibilityShowsLargeContentViewer()`` would be appropriate. On macOS, this value cannot be changed by users and does not affect the text size.

get · iOS 13.0+

layoutDirection

TypeScript
get layoutDirection(): LayoutDirection
Swift declaration
var layoutDirection: LayoutDirection { get set }

The layout direction associated with the current environment. Use this value to determine or set whether the environment uses a left-to-right or right-to-left direction.

set · iOS 13.0+

layoutDirection

TypeScript
set layoutDirection(value: LayoutDirection)
Swift declaration
var layoutDirection: LayoutDirection { get set }

The layout direction associated with the current environment. Use this value to determine or set whether the environment uses a left-to-right or right-to-left direction.

get · iOS 13.0+

allowsTightening

TypeScript
get allowsTightening(): boolean
Swift declaration
var allowsTightening: Bool { get set }

A Boolean value that indicates whether inter-character spacing should tighten to fit the text into the available space. The default value is `false`.

set · iOS 13.0+

allowsTightening

TypeScript
set allowsTightening(value: boolean)
Swift declaration
var allowsTightening: Bool { get set }

A Boolean value that indicates whether inter-character spacing should tighten to fit the text into the available space. The default value is `false`.

get · iOS 15.0+

headerProminence

TypeScript
get headerProminence(): Prominence
Swift declaration
var headerProminence: Prominence { get set }

The prominence to apply to section headers within a view. The default is ``Prominence/standard``.

set · iOS 15.0+

headerProminence

TypeScript
set headerProminence(value: Prominence)
Swift declaration
var headerProminence: Prominence { get set }

The prominence to apply to section headers within a view. The default is ``Prominence/standard``.

get · iOS 13.0+

legibilityWeight

TypeScript
get legibilityWeight(): (LegibilityWeight) | null
Swift declaration
var legibilityWeight: LegibilityWeight? { get set }

The font weight to apply to text. This value reflects the value of the Bold Text display setting found in the Accessibility settings.

set · iOS 13.0+

legibilityWeight

TypeScript
set legibilityWeight(value: (LegibilityWeight) | null)
Swift declaration
var legibilityWeight: LegibilityWeight? { get set }

The font weight to apply to text. This value reflects the value of the Bold Text display setting found in the Accessibility settings.

get · iOS 14.0+

redactionReasons

TypeScript
get redactionReasons(): RedactionReasons
Swift declaration
var redactionReasons: RedactionReasons { get set }

The current redaction reasons applied to the view hierarchy.

set · iOS 14.0+

redactionReasons

TypeScript
set redactionReasons(value: RedactionReasons)
Swift declaration
var redactionReasons: RedactionReasons { get set }

The current redaction reasons applied to the view hierarchy.

get · iOS 16.0+

contentTransition

TypeScript
get contentTransition(): ContentTransition
Swift declaration
var contentTransition: ContentTransition { get set }

The current method of animating the contents of views.

set · iOS 16.0+

contentTransition

TypeScript
set contentTransition(value: ContentTransition)
Swift declaration
var contentTransition: ContentTransition { get set }

The current method of animating the contents of views.

get · iOS 13.0+

verticalSizeClass

TypeScript
get verticalSizeClass(): (UserInterfaceSizeClass) | null
Swift declaration
@backDeployed(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
var verticalSizeClass: UserInterfaceSizeClass? { get set }

The vertical size class of this environment. You receive a ``UserInterfaceSizeClass`` value when you read this environment value. The value tells you about the amount of vertical space available to the view that reads it. You can read this size class like any other of the ``EnvironmentValues``, by creating a property with the ``Environment`` property wrapper: @Environment(\.verticalSizeClass) private var verticalSizeClass SwiftUI sets this size class based on several factors, including: * The current device type. * The orientation of the device. You can adjust the appearance of custom views by reading this 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 vertical size class is always ``UserInterfaceSizeClass/compact``. In macOS, and tvOS, it's always ``UserInterfaceSizeClass/regular``. Writing to the vertical size class in the environment before macOS 14.0, tvOS 17.0, and watchOS 10.0 is not supported.

set · iOS 13.0+

verticalSizeClass

TypeScript
set verticalSizeClass(value: (UserInterfaceSizeClass) | null)
Swift declaration
@backDeployed(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
var verticalSizeClass: UserInterfaceSizeClass? { get set }

The vertical size class of this environment. You receive a ``UserInterfaceSizeClass`` value when you read this environment value. The value tells you about the amount of vertical space available to the view that reads it. You can read this size class like any other of the ``EnvironmentValues``, by creating a property with the ``Environment`` property wrapper: @Environment(\.verticalSizeClass) private var verticalSizeClass SwiftUI sets this size class based on several factors, including: * The current device type. * The orientation of the device. You can adjust the appearance of custom views by reading this 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 vertical size class is always ``UserInterfaceSizeClass/compact``. In macOS, and tvOS, it's always ``UserInterfaceSizeClass/regular``. Writing to the vertical size class in the environment before macOS 14.0, tvOS 17.0, and watchOS 10.0 is not supported.

get · iOS 15.0+

backgroundMaterial

TypeScript
get backgroundMaterial(): (Material) | null
Swift declaration
var backgroundMaterial: Material? { get set }

The material underneath the current view. This value is `nil` if the current background isn't one of the standard materials. If you set a material, the standard content styles enable their vibrant rendering modes. You set this value by calling one of the background modifiers that takes a ``ShapeStyle``, like ``View/background(_:ignoresSafeAreaEdges:)`` or ``View/background(_:in:fillStyle:)``, and passing in a ``Material``. You can also set the value manually, using `nil` to disable vibrant rendering, or a ``Material`` instance to enable the vibrancy style associated with the specified material.

set · iOS 15.0+

backgroundMaterial

TypeScript
set backgroundMaterial(value: (Material) | null)
Swift declaration
var backgroundMaterial: Material? { get set }

The material underneath the current view. This value is `nil` if the current background isn't one of the standard materials. If you set a material, the standard content styles enable their vibrant rendering modes. You set this value by calling one of the background modifiers that takes a ``ShapeStyle``, like ``View/background(_:ignoresSafeAreaEdges:)`` or ``View/background(_:in:fillStyle:)``, and passing in a ``Material``. You can also set the value manually, using `nil` to disable vibrant rendering, or a ``Material`` instance to enable the vibrancy style associated with the specified material.

get · iOS 16.0+

isLuminanceReduced

TypeScript
get isLuminanceReduced(): boolean
Swift declaration
var isLuminanceReduced: Bool { get set }

A Boolean value that indicates whether the display or environment currently requires reduced luminance. When you detect this condition, lower the overall brightness of your view. For example, you can change large, filled shapes to be stroked, and choose less bright colors: @Environment(\.isLuminanceReduced) var isLuminanceReduced var body: some View { if isLuminanceReduced { Circle() .stroke(Color.gray, lineWidth: 10) } else { Circle() .fill(Color.white) } } In addition to the changes that you make, the system could also dim the display to achieve a suitable brightness. By reacting to `isLuminanceReduced`, you can preserve contrast and readability while helping to satisfy the reduced brightness requirement. > Note: On watchOS, the system typically sets this value to `true` when the user lowers their wrist, but the display remains on. Starting in watchOS 8, the system keeps your view visible on wrist down by default. If you want the system to blur the screen instead, as it did in earlier versions of watchOS, set the value for the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/WKSupportsAlwaysOnDisplay> key in your app's <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List> file to `false`.

set · iOS 16.0+

isLuminanceReduced

TypeScript
set isLuminanceReduced(value: boolean)
Swift declaration
var isLuminanceReduced: Bool { get set }

A Boolean value that indicates whether the display or environment currently requires reduced luminance. When you detect this condition, lower the overall brightness of your view. For example, you can change large, filled shapes to be stroked, and choose less bright colors: @Environment(\.isLuminanceReduced) var isLuminanceReduced var body: some View { if isLuminanceReduced { Circle() .stroke(Color.gray, lineWidth: 10) } else { Circle() .fill(Color.white) } } In addition to the changes that you make, the system could also dim the display to achieve a suitable brightness. By reacting to `isLuminanceReduced`, you can preserve contrast and readability while helping to satisfy the reduced brightness requirement. > Note: On watchOS, the system typically sets this value to `true` when the user lowers their wrist, but the display remains on. Starting in watchOS 8, the system keeps your view visible on wrist down by default. If you want the system to blur the screen instead, as it did in earlier versions of watchOS, set the value for the <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List/WKSupportsAlwaysOnDisplay> key in your app's <doc://com.apple.documentation/documentation/BundleResources/Information-Property-List> file to `false`.

get · iOS 13.0+

minimumScaleFactor

TypeScript
get minimumScaleFactor(): number
Swift declaration
var minimumScaleFactor: CGFloat { get set }

The minimum permissible proportion to shrink the font size to fit the text into the available space. In the example below, a label with a `minimumScaleFactor` of `0.5` draws its text in a font size as small as half of the actual font if needed to fit into the space next to the text input field: HStack { Text("This is a very long label:") .lineLimit(1) .minimumScaleFactor(0.5) TextField("My Long Text Field", text: $myTextField) .frame(width: 250, height: 50, alignment: .center) } ![A screenshot showing the effects of setting the minimumScaleFactor on the text in a view](SwiftUI-View-minimumScaleFactor.png) You can set the minimum scale factor to any value greater than `0` and less than or equal to `1`. The default value is `1`. SwiftUI uses this value to shrink text that doesn't fit in a view when it's okay to shrink the text. For example, a label with a `minimumScaleFactor` of `0.5` draws its text in a font size as small as half the actual font if needed.

set · iOS 13.0+

minimumScaleFactor

TypeScript
set minimumScaleFactor(value: number)
Swift declaration
var minimumScaleFactor: CGFloat { get set }

The minimum permissible proportion to shrink the font size to fit the text into the available space. In the example below, a label with a `minimumScaleFactor` of `0.5` draws its text in a font size as small as half of the actual font if needed to fit into the space next to the text input field: HStack { Text("This is a very long label:") .lineLimit(1) .minimumScaleFactor(0.5) TextField("My Long Text Field", text: $myTextField) .frame(width: 250, height: 50, alignment: .center) } ![A screenshot showing the effects of setting the minimumScaleFactor on the text in a view](SwiftUI-View-minimumScaleFactor.png) You can set the minimum scale factor to any value greater than `0` and less than or equal to `1`. The default value is `1`. SwiftUI uses this value to shrink text that doesn't fit in a view when it's okay to shrink the text. For example, a label with a `minimumScaleFactor` of `0.5` draws its text in a font size as small as half the actual font if needed.

get · iOS 17.0+

allowedDynamicRange

TypeScript
get allowedDynamicRange(): (Image_DynamicRange) | null
Swift declaration
var allowedDynamicRange: Image.DynamicRange? { get set }

The allowed dynamic range for the view, or nil.

set · iOS 17.0+

allowedDynamicRange

TypeScript
set allowedDynamicRange(value: (Image_DynamicRange) | null)
Swift declaration
var allowedDynamicRange: Image.DynamicRange? { get set }

The allowed dynamic range for the view, or nil.

get · iOS 13.0+

colorSchemeContrast

TypeScript
get colorSchemeContrast(): ColorSchemeContrast
Swift declaration
var colorSchemeContrast: ColorSchemeContrast { get }

The contrast associated with the color scheme of this environment. Read this environment value from within a view to find out if SwiftUI is currently displaying the view using ``ColorSchemeContrast/standard`` or ``ColorSchemeContrast/increased`` contrast. The value that you read depends entirely on user settings, and you can't change it. @Environment(\.colorSchemeContrast) private var colorSchemeContrast var body: some View { Text(colorSchemeContrast == .standard ? "Standard" : "Increased") } When adjusting your app's user interface to match the contrast, consider also checking the ``EnvironmentValues/colorScheme`` property to find out if SwiftUI is displaying the view with a light or dark appearance. For information, see <doc://com.apple.documentation/design/human-interface-guidelines/accessibility#Color-and-effects> in the Human Interface Guidelines. > Note: If you only need to provide different colors or images for different color scheme and contrast settings, do that in your app's Asset Catalog. See <doc://com.apple.documentation/documentation/Xcode/Asset-Management>.

get · iOS 13.0+

horizontalSizeClass

TypeScript
get horizontalSizeClass(): (UserInterfaceSizeClass) | null
Swift declaration
@backDeployed(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
var horizontalSizeClass: UserInterfaceSizeClass? { get set }

The horizontal size class of this environment. You receive a ``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``, by creating a property with the ``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`` presents a multicolumn view when the horizontal size class is ``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``. In macOS, and tvOS, it's always ``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.

set · iOS 13.0+

horizontalSizeClass

TypeScript
set horizontalSizeClass(value: (UserInterfaceSizeClass) | null)
Swift declaration
@backDeployed(before: macOS 14.0, tvOS 17.0, watchOS 10.0)
var horizontalSizeClass: UserInterfaceSizeClass? { get set }

The horizontal size class of this environment. You receive a ``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``, by creating a property with the ``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`` presents a multicolumn view when the horizontal size class is ``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``. In macOS, and tvOS, it's always ``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.

get · iOS 15.0+

symbolRenderingMode

TypeScript
get symbolRenderingMode(): (SymbolRenderingMode) | null
Swift declaration
var symbolRenderingMode: SymbolRenderingMode? { get set }

The current symbol rendering mode, or `nil` denoting that the mode is picked automatically using the current image and foreground style as parameters.

set · iOS 15.0+

symbolRenderingMode

TypeScript
set symbolRenderingMode(value: (SymbolRenderingMode) | null)
Swift declaration
var symbolRenderingMode: SymbolRenderingMode? { get set }

The current symbol rendering mode, or `nil` denoting that the mode is picked automatically using the current image and foreground style as parameters.

get · iOS 27.1+

toolbarVerticalEdge

TypeScript
get toolbarVerticalEdge(): (HorizontalEdge) | null
Swift declaration
var toolbarVerticalEdge: HorizontalEdge? { get }

The horizontal edge where the system places the vertical bar. This value reflects the system's preferred edge for the vertical bar in the current context, regardless of whether a vertical bar is currently visible. Use it to position custom bars or other UI relative to the system's bar placement. This value is read-only; the system determines the edge based on locale and device. Returns `nil` on devices and in contexts where the system never places a vertical bar — for example hardware without a vertical bar, or a size class or orientation in which no vertical bar is used. struct ContentView: View { @Environment(\.toolbarVerticalEdge) var toolbarVerticalEdge var body: some View { FloatingToolPalette() .frame(maxWidth: .infinity, alignment: toolbarVerticalEdge == .trailing ? .trailing : .leading) } }

get · iOS 13.0+

accessibilityEnabled

TypeScript
get accessibilityEnabled(): boolean
Swift declaration
var accessibilityEnabled: Bool { get set }

A Boolean value that indicates whether the user has enabled an assistive technology.

set · iOS 13.0+

accessibilityEnabled

TypeScript
set accessibilityEnabled(value: boolean)
Swift declaration
var accessibilityEnabled: Bool { get set }

A Boolean value that indicates whether the user has enabled an assistive technology.

get · iOS 17.0+

backgroundProminence

TypeScript
get backgroundProminence(): BackgroundProminence
Swift declaration
var backgroundProminence: BackgroundProminence { get set }

The prominence of the background underneath views associated with this environment. Foreground elements above an increased prominence background are typically adjusted to have higher contrast against a potentially vivid color, such as taking on a higher opacity monochrome appearance according to the `colorScheme`. System styles like `primary`, `secondary`, etc will automatically resolve to an appropriate style in this context. The property can be read and used for custom styled elements. In the example below, a custom star rating element is in a list row alongside some text. When the row is selected and has an increased prominence appearance, the text and star rating will update their appearance, the star rating replacing its use of yellow with the standard `secondary` style. struct RecipeList: View { var recipes: [Recipe] @Binding var selectedRecipe: Recipe.ID? var body: some View { List(recipes, selection: $selectedRecipe) { RecipeListRow(recipe: $0) } } } struct RecipeListRow: View { var recipe: Recipe var body: some View { VStack(alignment: .leading) { HStack(alignment: .firstTextBaseline) { Text(recipe.name) Spacer() StarRating(rating: recipe.rating) } Text(recipe.description) .foregroundStyle(.secondary) .lineLimit(2, reservesSpace: true) } } } private struct StarRating: View { var rating: Int @Environment(\.backgroundProminence) private var backgroundProminence var body: some View { HStack(spacing: 1) { ForEach(0..<rating, id: \.self) { _ in Image(systemName: "star.fill") } } .foregroundStyle(backgroundProminence == .increased ? AnyShapeStyle(.secondary) : AnyShapeStyle(.yellow)) .imageScale(.small) } } Note that the use of `backgroundProminence` was used by a view that was nested in additional stack containers within the row. This ensured that the value correctly reflected the environment within the list row itself, as opposed to the environment of the list as a whole. One way to ensure correct resolution would be to prefer using this in a custom ShapeStyle instead, for example: private struct StarRating: View { var rating: Int var body: some View { HStack(spacing: 1) { ForEach(0..<rating, id: \.self) { _ in Image(systemName: "star.fill") } } .foregroundStyle(FillStyle()) .imageScale(.small) } } extension StarRating { struct FillStyle: ShapeStyle { func resolve(in env: EnvironmentValues) -> some ShapeStyle { switch env.backgroundProminence { case .increased: return AnyShapeStyle(.secondary) default: return AnyShapeStyle(.yellow) } } } } Views like `List` and `Table` as well as standard shape styles like `ShapeStyle.selection` will automatically update the background prominence of foreground views. For custom backgrounds, this environment property can be explicitly set on views above custom backgrounds.

set · iOS 17.0+

backgroundProminence

TypeScript
set backgroundProminence(value: BackgroundProminence)
Swift declaration
var backgroundProminence: BackgroundProminence { get set }

The prominence of the background underneath views associated with this environment. Foreground elements above an increased prominence background are typically adjusted to have higher contrast against a potentially vivid color, such as taking on a higher opacity monochrome appearance according to the `colorScheme`. System styles like `primary`, `secondary`, etc will automatically resolve to an appropriate style in this context. The property can be read and used for custom styled elements. In the example below, a custom star rating element is in a list row alongside some text. When the row is selected and has an increased prominence appearance, the text and star rating will update their appearance, the star rating replacing its use of yellow with the standard `secondary` style. struct RecipeList: View { var recipes: [Recipe] @Binding var selectedRecipe: Recipe.ID? var body: some View { List(recipes, selection: $selectedRecipe) { RecipeListRow(recipe: $0) } } } struct RecipeListRow: View { var recipe: Recipe var body: some View { VStack(alignment: .leading) { HStack(alignment: .firstTextBaseline) { Text(recipe.name) Spacer() StarRating(rating: recipe.rating) } Text(recipe.description) .foregroundStyle(.secondary) .lineLimit(2, reservesSpace: true) } } } private struct StarRating: View { var rating: Int @Environment(\.backgroundProminence) private var backgroundProminence var body: some View { HStack(spacing: 1) { ForEach(0..<rating, id: \.self) { _ in Image(systemName: "star.fill") } } .foregroundStyle(backgroundProminence == .increased ? AnyShapeStyle(.secondary) : AnyShapeStyle(.yellow)) .imageScale(.small) } } Note that the use of `backgroundProminence` was used by a view that was nested in additional stack containers within the row. This ensured that the value correctly reflected the environment within the list row itself, as opposed to the environment of the list as a whole. One way to ensure correct resolution would be to prefer using this in a custom ShapeStyle instead, for example: private struct StarRating: View { var rating: Int var body: some View { HStack(spacing: 1) { ForEach(0..<rating, id: \.self) { _ in Image(systemName: "star.fill") } } .foregroundStyle(FillStyle()) .imageScale(.small) } } extension StarRating { struct FillStyle: ShapeStyle { func resolve(in env: EnvironmentValues) -> some ShapeStyle { switch env.backgroundProminence { case .increased: return AnyShapeStyle(.secondary) default: return AnyShapeStyle(.yellow) } } } } Views like `List` and `Table` as well as standard shape styles like `ShapeStyle.selection` will automatically update the background prominence of foreground views. For custom backgrounds, this environment property can be explicitly set on views above custom backgrounds.

get · iOS 17.0+

isHoverEffectEnabled

TypeScript
get isHoverEffectEnabled(): boolean
Swift declaration
var isHoverEffectEnabled: Bool { get set }

A Boolean value that indicates whether the view associated with this environment allows hover effects to be displayed. The default value is `true`.

set · iOS 17.0+

isHoverEffectEnabled

TypeScript
set isHoverEffectEnabled(value: boolean)
Swift declaration
var isHoverEffectEnabled: Bool { get set }

A Boolean value that indicates whether the view associated with this environment allows hover effects to be displayed. The default value is `true`.

get · iOS 27.1+

splitArrangementAxis

TypeScript
get splitArrangementAxis(): (Axis) | null
Swift declaration
var splitArrangementAxis: Axis? { get set }

The axis of the split for a view within a split arrangement view. Use this value to read the axis that a split arrangement is using to place its views. Views can adapt their layout or appearance based on whether the split is horizontal or vertical. The value is `nil` when the view is not contained within a split arrangement view. struct DetailsView: View { @Environment(\.splitArrangementAxis) var axis var body: some View { let layout: AnyLayout = axis == .horizontal ? AnyLayout(VStackLayout()) : AnyLayout(HStackLayout()) layout { Artwork() Metadata() } } }

set · iOS 27.1+

splitArrangementAxis

TypeScript
set splitArrangementAxis(value: (Axis) | null)
Swift declaration
var splitArrangementAxis: Axis? { get set }

The axis of the split for a view within a split arrangement view. Use this value to read the axis that a split arrangement is using to place its views. Views can adapt their layout or appearance based on whether the split is horizontal or vertical. The value is `nil` when the view is not contained within a split arrangement view. struct DetailsView: View { @Environment(\.splitArrangementAxis) var axis var body: some View { let layout: AnyLayout = axis == .horizontal ? AnyLayout(VStackLayout()) : AnyLayout(HStackLayout()) layout { Artwork() Metadata() } } }

get · iOS 15.0+

fontResolutionContext

TypeScript
get fontResolutionContext(): Font_Context
Swift declaration
var fontResolutionContext: Font.Context { get }

Information used to resolve a font. - SeeAlso: ``Font/resolve(in:)``

get · iOS 13.0+

multilineTextAlignment

TypeScript
get multilineTextAlignment(): TextAlignment
Swift declaration
var multilineTextAlignment: TextAlignment { get set }

An environment value that indicates how a text view aligns its lines when the content wraps or contains newlines. Set this value for a view hierarchy by applying the ``View/multilineTextAlignment(_:)`` view modifier. Views in the hierarchy that display text, like ``Text`` or ``TextEditor``, read the value from the environment and adjust their text alignment accordingly. This value has no effect on a ``Text`` view that contains only one line of text, because a text view has a width that exactly matches the width of its widest line. If you want to align an entire text view rather than its contents, set the aligment of its container, like a ``VStack`` or a frame that you create with the ``View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)`` modifier. > Note: You can use this value to control the alignment of a ``Text`` view that you create with the ``Text/init(_:style:)`` initializer to display localized dates and times, including when the view uses only a single line, but only when that view appears in a widget.

set · iOS 13.0+

multilineTextAlignment

TypeScript
set multilineTextAlignment(value: TextAlignment)
Swift declaration
var multilineTextAlignment: TextAlignment { get set }

An environment value that indicates how a text view aligns its lines when the content wraps or contains newlines. Set this value for a view hierarchy by applying the ``View/multilineTextAlignment(_:)`` view modifier. Views in the hierarchy that display text, like ``Text`` or ``TextEditor``, read the value from the environment and adjust their text alignment accordingly. This value has no effect on a ``Text`` view that contains only one line of text, because a text view has a width that exactly matches the width of its widest line. If you want to align an entire text view rather than its contents, set the aligment of its container, like a ``VStack`` or a frame that you create with the ``View/frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:)`` modifier. > Note: You can use this value to control the alignment of a ``Text`` view that you create with the ``Text/init(_:style:)`` initializer to display localized dates and times, including when the view uses only a single line, but only when that view appears in a widget.

get · iOS 26.0+

symbolVariableValueMode

TypeScript
get symbolVariableValueMode(): (SymbolVariableValueMode) | null
Swift declaration
var symbolVariableValueMode: SymbolVariableValueMode? { get set }

The current symbol variable value mode, or `nil` denoting that the mode is picked automatically.

set · iOS 26.0+

symbolVariableValueMode

TypeScript
set symbolVariableValueMode(value: (SymbolVariableValueMode) | null)
Swift declaration
var symbolVariableValueMode: SymbolVariableValueMode? { get set }

The current symbol variable value mode, or `nil` denoting that the mode is picked automatically.

get · iOS 14.0+

accessibilityShowBorders

TypeScript
get accessibilityShowBorders(): boolean
Swift declaration
@backDeployed(before: iOS 26.1, macOS 26.1, tvOS 26.1, watchOS 26.1, visionOS 26.1)
var accessibilityShowBorders: Bool { get }

Whether the system preference for Show Borders is enabled. On macOS 27 and later, the system provides a dedicated Show Borders setting in System Settings. On earlier versions of macOS, this value is true when Increased Contrast is enabled. When this value is true, draw interactive custom controls such as buttons with clearly visible edges so they remain distinguishable at any window size: struct BorderedButton: View { @Environment(\.accessibilityShowBorders) var showBorders var body: some View { Label("Archive", systemImage: "archivebox") .padding(8) .overlay { if showBorders { RoundedRectangle(cornerRadius: 8) .stroke(.secondary) } } } }

get · iOS 18.0+

materialActiveAppearance

TypeScript
get materialActiveAppearance(): MaterialActiveAppearance
Swift declaration
var materialActiveAppearance: MaterialActiveAppearance { get set }

The behavior materials should use for their active state, defaulting to `automatic`.

set · iOS 18.0+

materialActiveAppearance

TypeScript
set materialActiveAppearance(value: MaterialActiveAppearance)
Swift declaration
var materialActiveAppearance: MaterialActiveAppearance { get set }

The behavior materials should use for their active state, defaulting to `automatic`.

get · iOS 27.1+

overlayArrangementZIndex

TypeScript
get overlayArrangementZIndex(): number
Swift declaration
var overlayArrangementZIndex: Int { get set }

The z-index for a view within an overlay arrangement view. Use this value to read the z-ordering of a view when it is placed in an overlay arrangement. Views with a higher z-index are rendered on top of views with a lower z-index. struct PlayerView: View { @Environment(\.overlayArrangementZIndex) var zIndex var body: some View { VideoPlayerControls() .opacity(zIndex == 0 ? 1.0 : 0.5) } }

set · iOS 27.1+

overlayArrangementZIndex

TypeScript
set overlayArrangementZIndex(value: number)
Swift declaration
var overlayArrangementZIndex: Int { get set }

The z-index for a view within an overlay arrangement view. Use this value to read the z-ordering of a view when it is placed in an overlay arrangement. Views with a higher z-index are rendered on top of views with a lower z-index. struct PlayerView: View { @Environment(\.overlayArrangementZIndex) var zIndex var body: some View { VideoPlayerControls() .opacity(zIndex == 0 ? 1.0 : 0.5) } }

get · iOS 26.0+

symbolColorRenderingMode

TypeScript
get symbolColorRenderingMode(): (SymbolColorRenderingMode) | null
Swift declaration
var symbolColorRenderingMode: SymbolColorRenderingMode? { get set }

The property specifying how symbol images fill their layers, or nil to use the default fill style.

set · iOS 26.0+

symbolColorRenderingMode

TypeScript
set symbolColorRenderingMode(value: (SymbolColorRenderingMode) | null)
Swift declaration
var symbolColorRenderingMode: SymbolColorRenderingMode? { get set }

The property specifying how symbol images fill their layers, or nil to use the default fill style.

get · iOS 13.0+

accessibilityInvertColors

TypeScript
get accessibilityInvertColors(): boolean
Swift declaration
var accessibilityInvertColors: Bool { get }

Whether the system preference for Invert Colors is enabled. If this property's value is true then the display will be inverted. In these cases it may be needed for UI drawing to be adjusted to in order to display optimally when inverted.

get · iOS 13.0+

accessibilityReduceMotion

TypeScript
get accessibilityReduceMotion(): boolean
Swift declaration
var accessibilityReduceMotion: Bool { get }

Whether the system preference for Reduce Motion is enabled. If this property's value is true, UI should avoid large animations, especially those that simulate the third dimension.

get · iOS 14.0+ · Deprecated in iOS 1000.0

accessibilityShowButtonShapes

TypeScript
get accessibilityShowButtonShapes(): boolean
Swift declaration
var accessibilityShowButtonShapes: Bool { get }

Whether the system preference for Show Button Shapes is enabled. If this property's value is true, interactive custom controls such as buttons should be drawn in such a way that their edges and borders are clearly visible.

get · iOS 15.0+

accessibilityVoiceOverEnabled

TypeScript
get accessibilityVoiceOverEnabled(): boolean
Swift declaration
var accessibilityVoiceOverEnabled: Bool { get }

A Boolean value that indicates whether the VoiceOver screen reader is in use. The state changes as the user turns on or off the VoiceOver screen reader.

get · iOS 17.0+

accessibilityDimFlashingLights

TypeScript
get accessibilityDimFlashingLights(): boolean
Swift declaration
var accessibilityDimFlashingLights: Bool { get }

Whether the setting to reduce flashing or strobing lights in video content is on. This setting can also be used to determine if UI in playback controls should be shown to indicate upcoming content that includes flashing or strobing lights.

get · iOS 17.0+

accessibilityPlayAnimatedImages

TypeScript
get accessibilityPlayAnimatedImages(): boolean
Swift declaration
var accessibilityPlayAnimatedImages: Bool { get }

Whether the setting for playing animations in an animated image is on. When this value is false, any presented image that contains animation should not play automatically.

get · iOS 13.0+

accessibilityReduceTransparency

TypeScript
get accessibilityReduceTransparency(): boolean
Swift declaration
var accessibilityReduceTransparency: Bool { get }

Whether the system preference for Reduce Transparency is enabled. If this property's value is true, UI (mainly window) backgrounds should not be semi-transparent; they should be opaque.

get · iOS 15.0+

accessibilitySwitchControlEnabled

TypeScript
get accessibilitySwitchControlEnabled(): boolean
Swift declaration
var accessibilitySwitchControlEnabled: Bool { get }

A Boolean value that indicates whether the Switch Control motor accessibility feature is in use. The state changes as the user turns on or off the Switch Control feature.

get · iOS 16.0+

contentTransitionAddsDrawingGroup

TypeScript
get contentTransitionAddsDrawingGroup(): boolean
Swift declaration
var contentTransitionAddsDrawingGroup: Bool { get set }

A Boolean value that controls whether views that render content transitions use GPU-accelerated rendering. Setting this value to `true` causes SwiftUI to wrap content transitions with a ``View/drawingGroup(opaque:colorMode:)`` modifier.

set · iOS 16.0+

contentTransitionAddsDrawingGroup

TypeScript
set contentTransitionAddsDrawingGroup(value: boolean)
Swift declaration
var contentTransitionAddsDrawingGroup: Bool { get set }

A Boolean value that controls whether views that render content transitions use GPU-accelerated rendering. Setting this value to `true` causes SwiftUI to wrap content transitions with a ``View/drawingGroup(opaque:colorMode:)`` modifier.

get · iOS 18.0+

accessibilityAssistiveAccessEnabled

TypeScript
get accessibilityAssistiveAccessEnabled(): boolean
Swift declaration
var accessibilityAssistiveAccessEnabled: Bool { get }

A Boolean value that indicates whether Assistive Access is in use.

get · iOS 13.0+

accessibilityDifferentiateWithoutColor

TypeScript
get accessibilityDifferentiateWithoutColor(): boolean
Swift declaration
var accessibilityDifferentiateWithoutColor: Bool { get }

Whether the system preference for Differentiate without Color is enabled. If this is true, UI should not convey information using color alone and instead should use shapes or glyphs to convey information.

get · iOS 15.0+

accessibilityLargeContentViewerEnabled

TypeScript
get accessibilityLargeContentViewerEnabled(): boolean
Swift declaration
var accessibilityLargeContentViewerEnabled: Bool { get }

Whether the Large Content Viewer is enabled. The system can automatically provide a large content view with ``View/accessibilityShowsLargeContentViewer()`` or you can provide your own with ``View/accessibilityShowsLargeContentViewer(_:)``. While it is not necessary to check this value before adding a large content view, it may be helpful if you need to adjust the behavior of a gesture. For example, a button with a long press handler might increase its long press duration so the user can read the text in the large content viewer first.

get · iOS 26.4+

accessibilityReduceHighlightingEffects

TypeScript
get accessibilityReduceHighlightingEffects(): boolean
Swift declaration
var accessibilityReduceHighlightingEffects: Bool { get }

Whether the system preference for Reduce Bright Effects is enabled. If this property's value is true, controls, such as buttons, should be drawn in such a way that minimizes highlighting and flashing of onscreen elements.

get · iOS 26.4+

accessibilityPrefersCrossFadeTransitions

TypeScript
get accessibilityPrefersCrossFadeTransitions(): boolean
Swift declaration
var accessibilityPrefersCrossFadeTransitions: Bool { get set }

A Boolean value that indicates whether the Reduce Motion and the Prefer Cross-Fade Transitions settings are in an enabled state. If this property's value is true, UI should avoid Slide animations and prefer Cross-Fade transitions instead On macOS, this value returns solely whether the Reduce Motion setting is in an enabled state. On watchOS, this value always returns false.

set · iOS 26.4+

accessibilityPrefersCrossFadeTransitions

TypeScript
set accessibilityPrefersCrossFadeTransitions(value: boolean)
Swift declaration
var accessibilityPrefersCrossFadeTransitions: Bool { get set }

A Boolean value that indicates whether the Reduce Motion and the Prefer Cross-Fade Transitions settings are in an enabled state. If this property's value is true, UI should avoid Slide animations and prefer Cross-Fade transitions instead On macOS, this value returns solely whether the Reduce Motion setting is in an enabled state. On watchOS, this value always returns false.

get · iOS 13.0+

font

TypeScript
get font(): (Font) | null
Swift declaration
var font: Font? { get set }

The default font of this environment.

set · iOS 13.0+

font

TypeScript
set font(value: (Font) | null)
Swift declaration
var font: Font? { get set }

The default font of this environment.

get · iOS 13.0+

locale

TypeScript
get locale(): _Foundation_Locale
Swift declaration
var locale: Locale { get set }

The current locale that views should use.

set · iOS 13.0+

locale

TypeScript
set locale(value: _Foundation_Locale)
Swift declaration
var locale: Locale { get set }

The current locale that views should use.

get · iOS 14.0+

openURL

TypeScript
get openURL(): Promise<OpenURLAction>
Swift declaration
@MainActor @preconcurrency var openURL: OpenURLAction { get set }

An action that opens a URL. Read this environment value to get an ``OpenURLAction`` instance for a given ``Environment``. Call the instance to open a URL. You call the instance directly because it defines a ``OpenURLAction/callAsFunction(_:)`` method that Swift calls when you call the instance. For example, you can open a web site when the user taps a button: struct OpenURLExample: View { @Environment(\.openURL) private var openURL var body: some View { Button { if let url = URL(string: "https://www.example.com") { openURL(url) } } label: { Label("Get Help", systemImage: "person.fill.questionmark") } } } If you want to know whether the action succeeds, add a completion handler that takes a Boolean value. In this case, Swift implicitly calls the ``OpenURLAction/callAsFunction(_:completion:)`` method instead. That method calls your completion handler after it determines whether it can open the URL, but possibly before it finishes opening the URL. You can add a handler to the example above so that it prints the outcome to the console: openURL(url) { accepted in print(accepted ? "Success" : "Failure") } The system provides a default open URL action with behavior that depends on the contents of the URL. For example, the default action opens a Universal Link in the associated app if possible, or in the user’s default web browser if not. You can also set a custom action using the ``View/environment(_:_:)`` view modifier. Any views that read the action from the environment, including the built-in ``Link`` view and ``Text`` views with markdown links, or links in attributed strings, use your action. Initialize an action by calling the ``OpenURLAction/init(handler:)`` initializer with a handler that takes a URL and returns an ``OpenURLAction/Result``: Text("Visit [Example Company](https://www.example.com) for details.") .environment(\.openURL, OpenURLAction { url in handleURL(url) // Define this method to take appropriate action. return .handled }) SwiftUI translates the value that your custom action's handler returns into an appropriate Boolean result for the action call. For example, a view that uses the action declared above receives `true` when calling the action, because the handler always returns ``OpenURLAction/Result/handled``.

set · iOS 14.0+

openURL

TypeScript
setOpenURL(value: OpenURLAction): Promise<void>
Swift declaration
@MainActor @preconcurrency var openURL: OpenURLAction { get set }

An action that opens a URL. Read this environment value to get an ``OpenURLAction`` instance for a given ``Environment``. Call the instance to open a URL. You call the instance directly because it defines a ``OpenURLAction/callAsFunction(_:)`` method that Swift calls when you call the instance. For example, you can open a web site when the user taps a button: struct OpenURLExample: View { @Environment(\.openURL) private var openURL var body: some View { Button { if let url = URL(string: "https://www.example.com") { openURL(url) } } label: { Label("Get Help", systemImage: "person.fill.questionmark") } } } If you want to know whether the action succeeds, add a completion handler that takes a Boolean value. In this case, Swift implicitly calls the ``OpenURLAction/callAsFunction(_:completion:)`` method instead. That method calls your completion handler after it determines whether it can open the URL, but possibly before it finishes opening the URL. You can add a handler to the example above so that it prints the outcome to the console: openURL(url) { accepted in print(accepted ? "Success" : "Failure") } The system provides a default open URL action with behavior that depends on the contents of the URL. For example, the default action opens a Universal Link in the associated app if possible, or in the user’s default web browser if not. You can also set a custom action using the ``View/environment(_:_:)`` view modifier. Any views that read the action from the environment, including the built-in ``Link`` view and ``Text`` views with markdown links, or links in attributed strings, use your action. Initialize an action by calling the ``OpenURLAction/init(handler:)`` initializer with a handler that takes a URL and returns an ``OpenURLAction/Result``: Text("Visit [Example Company](https://www.example.com) for details.") .environment(\.openURL, OpenURLAction { url in handleURL(url) // Define this method to take appropriate action. return .handled }) SwiftUI translates the value that your custom action's handler returns into an appropriate Boolean result for the action call. For example, a view that uses the action declared above receives `true` when calling the action, because the handler always returns ``OpenURLAction/Result/handled``.

get · iOS 13.0+

calendar

TypeScript
get calendar(): _Foundation_Calendar
Swift declaration
var calendar: Calendar { get set }

The current calendar that views should use when handling dates.

set · iOS 13.0+

calendar

TypeScript
set calendar(value: _Foundation_Calendar)
Swift declaration
var calendar: Calendar { get set }

The current calendar that views should use when handling dates.

get · iOS 14.0+

textCase

TypeScript
get textCase(): (Text_Case) | null
Swift declaration
var textCase: Text.Case? { get set }

A stylistic override to transform the case of `Text` when displayed, using the environment's locale. The default value is `nil`, displaying the `Text` without any case changes.

set · iOS 14.0+

textCase

TypeScript
set textCase(value: (Text_Case) | null)
Swift declaration
var textCase: Text.Case? { get set }

A stylistic override to transform the case of `Text` when displayed, using the environment's locale. The default value is `nil`, displaying the `Text` without any case changes.

get · iOS 13.0+

timeZone

TypeScript
get timeZone(): _Foundation_TimeZone
Swift declaration
var timeZone: TimeZone { get set }

The current time zone that views should use when handling dates.

set · iOS 13.0+

timeZone

TypeScript
set timeZone(value: _Foundation_TimeZone)
Swift declaration
var timeZone: TimeZone { get set }

The current time zone that views should use when handling dates.

get · iOS 13.0+

isEnabled

TypeScript
get isEnabled(): boolean
Swift declaration
var isEnabled: Bool { get set }

A Boolean value that indicates whether the view associated with this environment allows user interaction. The default value is `true`.

set · iOS 13.0+

isEnabled

TypeScript
set isEnabled(value: boolean)
Swift declaration
var isEnabled: Bool { get set }

A Boolean value that indicates whether the view associated with this environment allows user interaction. The default value is `true`.

get · iOS 13.0+

lineLimit

TypeScript
get lineLimit(): (number) | null
Swift declaration
var lineLimit: Int? { get set }

The maximum number of lines that text can occupy in a view. The maximum number of lines is `1` if the value is less than `1`. If the value is `nil`, the text uses as many lines as required. The default is `nil`.

set · iOS 13.0+

lineLimit

TypeScript
set lineLimit(value: (number) | null)
Swift declaration
var lineLimit: Int? { get set }

The maximum number of lines that text can occupy in a view. The maximum number of lines is `1` if the value is less than `1`. If the value is `nil`, the text uses as many lines as required. The default is `nil`.

init · iOS 13.0+

init

TypeScript
static init(): EnvironmentValues
Swift declaration
init()

Creates an environment values instance. You don't typically create an instance of ``EnvironmentValues`` directly. Doing so would provide access only to default values that don't update based on system settings or device characteristics. Instead, you rely on an environment values' instance that SwiftUI manages for you when you use the ``Environment`` property wrapper and the ``View/environment(_:_:)`` view modifier.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

EnvironmentValues.subscript(_:)

Passing a Swift type itself is not supported.

EnvironmentValues.subscript(_:)

Passing a Swift type itself is not supported.

All SwiftUICore types →