<!--
{
  "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/Entry()",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5Entryyycfm"
  },
  "title" : "Entry()"
}
-->

# Entry()

Creates an environment values, transaction, container values,
or focused values entry.

```
@attached(accessor) @attached(peer, names: prefixed(__Key_)) macro Entry()
```

## Environment Values

Create [`EnvironmentValues`](/documentation/SwiftUI/EnvironmentValues) entries by extending the [`EnvironmentValues`](/documentation/SwiftUI/EnvironmentValues)
structure with new properties and attaching the @Entry macro
to the variable declarations:

```swift
extension EnvironmentValues {
    @Entry var myCustomValue: String = "Default value"
    @Entry var anotherCustomValue = true
}
```

## Transaction Values

Create [`Transaction`](/documentation/SwiftUI/Transaction) entries by extending the [`Transaction`](/documentation/SwiftUI/Transaction)
structure with new properties and attaching the @Entry macro
to the variable declarations:

```swift
extension Transaction {
    @Entry var myCustomValue: String = "Default value"
}
```

## Container Values

Create [`ContainerValues`](/documentation/SwiftUI/ContainerValues) entries by extending the [`ContainerValues`](/documentation/SwiftUI/ContainerValues)
structure with new properties and attaching the @Entry macro
to the variable declarations:

```swift
extension ContainerValues {
    @Entry var myCustomValue: String = "Default value"
}
```

## Focused Values

Since the default value for [`FocusedValues`](/documentation/SwiftUI/FocusedValues) is always `nil`,
[`FocusedValues`](/documentation/SwiftUI/FocusedValues) entries cannot specify a different default value and
must have an Optional type.

Create [`FocusedValues`](/documentation/SwiftUI/FocusedValues) entries by extending the
[`FocusedValues`](/documentation/SwiftUI/FocusedValues) structure with new properties and attaching
the @Entry macro to the variable declarations:

```swift
extension FocusedValues {
    @Entry var myCustomValue: String?
}
```

---

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)