<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/keyboardType(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE12keyboardTypeyQrSo010UIKeyboardE0VF"
  },
  "title" : "keyboardType(_:)"
}
-->

# keyboardType(_:)

Sets the keyboard type for this view.

```
nonisolated func keyboardType(_ type: UIKeyboardType) -> some View
```

## Parameters

`type`

One of the keyboard types defined in the
<doc://com.apple.documentation/documentation/UIKit/UIKeyboardType> enumeration.

## Discussion

Use `keyboardType(_:)` to specify the keyboard type to use for text
entry. A number of different keyboard types are available to meet
specialized input needs, such as entering email addresses or phone
numbers.

The example below presents a [`TextField`](/documentation/SwiftUI/TextField) to input an email address.
Setting the text field’s keyboard type to `.emailAddress` ensures the
user can only enter correctly formatted email addresses.

```
TextField("someone@example.com", text: $emailAddress)
    .keyboardType(.emailAddress)
```

There are several different kinds of specialized keyboard types
available though the
<doc://com.apple.documentation/documentation/UIKit/UIKeyboardType> enumeration. To
specify the default system keyboard type, use `.default`.

![A screenshot showing the use of a specialized keyboard type with a](images/com.apple.SwiftUI/SwiftUI-View-keyboardType@2x.png)

---

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)