<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/AttributedTextSelection/Attributes",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI23AttributedTextSelectionV10AttributesV"
  },
  "title" : "AttributedTextSelection.Attributes"
}
-->

# AttributedTextSelection.Attributes

A sequence of all attribute values a selection has in a certain text.

```
struct Attributes<Text>
```

## Overview

The values of a selection are the attribute values of each run that is
fully or partially selected, or the typing attributes in the case the
selection is an insertion point.

By default, the sequence contains the attribute container for every
run or the typing attributes. Use the [`AttributedTextSelection.Attributes`](/documentation/SwiftUI/AttributedTextSelection/Attributes)’ subscript to
obtain only the values for a single attribute:

```
selection.attributes(in: text)[\.foregroundColor].contains(.red)
```

## Topics

### Subscripts

[`subscript(_:)`](/documentation/SwiftUI/AttributedTextSelection/Attributes/subscript(_:))

Returns a sequence which iterates of the values of a single
attribute.

## Relationships

### Conforms To

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

---

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)