<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TextField/init(text:prompt:label:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI9TextFieldV4text6prompt5labelACyxGAA7BindingVySSG_AA0C0VSgxyXEtcfc"
  },
  "title" : "init(text:prompt:label:)"
}
-->

# init(text:prompt:label:)

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

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

## Parameters

`text`

The text to display and edit.

`prompt`

A `Text` representing the prompt of the text field
which provides users with guidance on what to type into the text
field.

`label`

A view that describes the purpose of the text field.

## Discussion

Use the [`onSubmit(of:_:)`](/documentation/SwiftUI/View/onSubmit(of:_:)) modifier to invoke an action
whenever the user submits this text field.

---

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)