<!--
{
  "availability" : [
    "iOS: 13.0.0 - 27.0.0",
    "iPadOS: 13.0.0 - 27.0.0",
    "macCatalyst: 13.0.0 - 27.0.0",
    "macOS: 10.15.0 - 27.0.0",
    "tvOS: 13.0.0 - 27.0.0",
    "visionOS: 1.0.0 - 27.0.0",
    "watchOS: 6.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TextField/init(_:value:formatter:onEditingChanged:onCommit:)-6ab2i",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI9TextFieldVA2A0C0VRszrlE_5value9formatter16onEditingChanged0G6CommitACyAEGAA18LocalizedStringKeyV_AA7BindingVyqd__GSo11NSFormatterCySbcyyctclufc"
  },
  "title" : "init(_:value:formatter:onEditingChanged:onCommit:)"
}
-->

# init(_:value:formatter:onEditingChanged:onCommit:)

Creates an instance which binds over an arbitrary type, `T`.

```
nonisolated init<V>(_ titleKey: LocalizedStringKey, value: Binding<V>, formatter: Formatter, onEditingChanged: @escaping (Bool) -> Void, onCommit: @escaping () -> Void)
```

## Parameters

`titleKey`

The key for the localized title of the text field,
describing its purpose.

`value`

The underlying value to be edited.

`formatter`

A formatter to use when converting between the
string the user edits and the underlying value of type `T`.
In the event that `formatter` is unable to perform the conversion,
`binding.value` isn’t modified.

`onEditingChanged`

The action to perform when the user
begins editing `text` and after the user finishes editing `text`.
The closure receives a Boolean value that indicates the editing
status: `true` when the user begins editing, `false` when they
finish.

`onCommit`

An action to perform when the user performs an action
(for example, when the user presses the Return key) while the text
field has focus.

---

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)