<!--
{
  "availability" : [
    "macOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/textContentType(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE15textContentTypeyQrSo06NSTexteF0aSgF::OverloadGroup"
  },
  "title" : "textContentType(_:)"
}
-->

# textContentType(_:)

Sets the text content type for this view, which the system uses to
offer suggestions while the user enters text on macOS.

```
nonisolated func textContentType(_ textContentType: NSTextContentType?) -> some View
```

## Parameters

`textContentType`

One of the content types available in the
<doc://com.apple.documentation/documentation/AppKit/NSTextContentType>
structure that identify the semantic meaning expected for a text-entry
area.

## Discussion

Use this method to set the content type for input text.
For example, you can configure a [`TextField`](/documentation/SwiftUI/TextField) for the entry of a
username:

```
TextField("Enter your username", text: $username)
    .textContentType(.username)
```

---

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)