---
title: "init(_:text:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/securefield/init(_:text:)"
---

# init(_:text:)

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

## Declaration

```swift
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

Discussion Use the onSubmit(of:_:) modifier to invoke an action whenever someone submits this secure field — for example, by pressing the Return key.

## See Also

### Creating a secure text field

- [init(_:text:prompt:)](swiftui/securefield/init(_:text:prompt:).md)
- [init(text:prompt:label:)](swiftui/securefield/init(text:prompt:label:).md)
