<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSAttributedString/TextHighlightStyle",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@T@NSTextHighlightStyle"
  },
  "title" : "NSAttributedString.TextHighlightStyle"
}
-->

# NSAttributedString.TextHighlightStyle

Constants that specify the type of highlight to apply to text.

```
struct TextHighlightStyle
```

## Overview

Use an [`NSAttributedString.TextHighlightStyle`](/documentation/Foundation/NSAttributedString/TextHighlightStyle) structure as the value of the [`textHighlightStyle`](/documentation/Foundation/NSAttributedString/Key/textHighlightStyle) attribute. That attribute applies a highlight to the text to emphasize it. The highlight contributes a background color and a contrasting foreground color to the text.

## Topics

### Getting the highlight styles

[`static let `default`: NSAttributedString.TextHighlightStyle`](/documentation/Foundation/NSAttributedString/TextHighlightStyle/default)

The default highlight style to apply to text.

### Creating a highlight style

[`init(String)`](/documentation/Foundation/NSAttributedString/TextHighlightStyle/init(_:))

[`init(rawValue: String)`](/documentation/Foundation/NSAttributedString/TextHighlightStyle/init(rawValue:))

## Relationships

### Conforms To

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

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

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

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

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

---

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)