---
title: "attributes(in:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/attributedtextselection/attributes(in:)"
---

# attributes(in:)

Obtain a lazy sequence of all attribute values the selection has in a given text.

## Declaration

```swift
func attributes(in text: AttributedString) -> AttributedTextSelection.Attributes<AttributedString>
```

## Discussion

Discussion The attribute 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’ subscript to obtain only the values for a single attribute: selection.attributes(in: text)[\.foregroundColor].contains(.red)
