<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TextEditor/init(text:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI10TextEditorV4textAcA7BindingVySSG_tcfc"
  },
  "title" : "init(text:)"
}
-->

# init(text:)

Creates a plain text editor.

```
nonisolated init(text: Binding<String>)
```

## Parameters

`text`

A [`Binding`](/documentation/SwiftUI/Binding) to the variable containing the
text to edit.

## Discussion

Use a [`TextEditor`](/documentation/SwiftUI/TextEditor) instance to create a view in which users can enter
and edit long-form text.

In this example, the text editor renders gray text using the 13
point Helvetica Neue font with 5 points of spacing between each line:

```
struct TextEditingView: View {
    @State private var fullText: String = "This is some editable text..."

    var body: some View {
        TextEditor(text: $fullText)
            .foregroundColor(Color.gray)
            .font(.custom("HelveticaNeue", size: 13))
            .lineSpacing(5)
    }
}
```

You can define the styling for the text within the view, including the
text color, font, and line spacing. You define these styles by applying
standard view modifiers to the view.

The default text editor doesn’t support rich text, such as styling of
individual elements within the editor’s view. The styles you set apply
globally to all text in the view.

---

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)