<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/LayoutValueKey/defaultValue",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI14LayoutValueKeyP07defaultD00D0QzvpZ"
  },
  "title" : "defaultValue"
}
-->

# defaultValue

The default value of the key.

```
static var defaultValue: Self.Value { get }
```

## Discussion

Implement the `defaultValue` property for a type that conforms to the
[`LayoutValueKey`](/documentation/SwiftUI/LayoutValueKey) protocol. For example, you can create a `Flexibility`
layout value that defaults to `nil`:

```
private struct Flexibility: LayoutValueKey {
    static let defaultValue: CGFloat? = nil
}
```

The type that you declare for the `defaultValue` sets the layout
key’s [`Value`](/documentation/SwiftUI/LayoutValueKey/Value) associated type. The Swift compiler infers the key’s
associated type in the above example as an optional
<doc://com.apple.documentation/documentation/CoreFoundation/CGFloat-swift.struct>.

Any view that you don’t explicitly set a value for uses the default
value. Override the default value for a view using the
[`layoutValue(key:value:)`](/documentation/SwiftUI/View/layoutValue(key:value:)) modifier.

---

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)