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

# init(_:text:onCommit:)

Creates an instance.

## Declaration

```swift
nonisolated init(_ titleKey: LocalizedStringKey, text: Binding<String>, onCommit: @escaping () -> Void)
```

## Parameters

- `titleKey`: The key for the localized title of self, describing its purpose.
- `text`: The text to display and edit.
- `onCommit`: The action to perform when the user performs an action (usually pressing the Return key) while the secure field has focus.
