<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UITextItem",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UITextItem"
  },
  "title" : "UITextItem"
}
-->

# UITextItem

An object for attaching custom actions and menus to links, text attachments, or other specific text in a text view.

```
@MainActor class UITextItem
```

## Overview

A text item represents a link with a URL destination, a custom tag for a topic that you specify in your app, or a text attachment in a text view. In your text view’s [`UITextViewDelegate`](/documentation/UIKit/UITextViewDelegate), implement [`textView(_:primaryActionFor:defaultAction:)`](/documentation/UIKit/UITextViewDelegate/textView(_:primaryActionFor:defaultAction:)) to provide a custom action when someone interacts with a text item. Implement [`textView(_:menuConfigurationFor:defaultMenu:)`](/documentation/UIKit/UITextViewDelegate/textView(_:menuConfigurationFor:defaultMenu:)) to provide a custom menu for a text item.

## Topics

### Specifying the content type

[`content`](/documentation/UIKit/UITextItem/content-swift.property)

The content type and related value of the text item.

[`Content`](/documentation/UIKit/UITextItem/Content-swift.enum)

Constants that describe and capture the type of content a text item represents along with a specific related value.

[`contentType`](/documentation/UIKit/UITextItem/contentType)

The content type and related value of the text item.

### Specifying the range

[`range`](/documentation/UIKit/UITextItem/range)

The range that delineates the text item in an attributed string.

### Creating a menu

[`MenuConfiguration`](/documentation/UIKit/UITextItem/MenuConfiguration)

An object that describes what type of menu and preview to show for a text item.

### Getting the value

[`link`](/documentation/UIKit/UITextItem/link)

The URL associated with the link text.

[`textAttachment`](/documentation/UIKit/UITextItem/textAttachment)

The attachment for with the text item.

[`tagIdentifier`](/documentation/UIKit/UITextItem/tagIdentifier)

The tag associated with the text item.

## Relationships

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Equatable`](/documentation/Swift/Equatable)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)