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

# init(text:prompt:label:)

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

## Declaration

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

Discussion Use the onSubmit(of:_:) modifier to invoke an action whenever the user submits this text field.

## See Also

### Creating a text field with a string

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