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

# init(text:prompt:label:)

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

## Declaration

```swift
nonisolated init(text: Binding<String>, prompt: Text? = nil, @ContentBuilder label: () -> Label)
```

## Parameters

- `text`: A binding to the text that the field displays and edits.
- `prompt`: A doc://com.apple.SwiftUI/documentation/SwiftUI/Text view that represents the secure field’s prompt. The prompt provides guidance on what people should type into the secure field.
- `label`: A view that describes the purpose of the secure field.

## 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:)](swiftui/securefield/init(_:text:).md)
- [init(_:text:prompt:)](swiftui/securefield/init(_:text:prompt:).md)
