<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/TextField/init(_:text:axis:)-8rujz",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI9TextFieldVA2A0C0VRszrlE_4text4axisACyAEGqd___AA7BindingVySSGAA4AxisOtcSyRd__lufc"
  },
  "title" : "init(_:text:axis:)"
}
-->

# init(_:text:axis:)

Creates a text field with a preferred axis and a text label generated
from a title string.

```
nonisolated init<S>(_ title: S, text: Binding<String>, axis: Axis) where S : StringProtocol
```

## Parameters

`title`

The title of the text view, describing its purpose.

`text`

The text to display and edit.

`axis`

The axis in which to scroll text when it doesn’t fit
in the available space.

## Discussion

Specify a preferred axis in which the text field should scroll
its content when it does not fit in the available space. Depending
on the style of the field, this axis may not be respected.

Use the `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)