<!--
{
  "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/SecureField/init(_:text:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11SecureFieldVA2A4TextVRszrlE_4textACyAEGAA18LocalizedStringKeyV_AA7BindingVySSGtcfc::OverloadGroup"
  },
  "title" : "init(_:text:)"
}
-->

# init(_:text:)

Creates a secure field with a prompt generated from a `Text`.

```
@export(implementation) nonisolated init(_ titleKey: LocalizedStringKey, text: Binding<String>)
```

## Parameters

`titleKey`

The key for the field’s localized title. The title
describes the purpose of the field.

`text`

A binding to the text that the field displays and edits.

## Discussion

Use the [`onSubmit(of:_:)`](/documentation/SwiftUI/View/onSubmit(of:_:)) modifier to invoke an action
whenever someone submits this secure field — for example, by
pressing the Return key.

---

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)