---
title: AttributeScope
framework: foundation
role: symbol
role_heading: Protocol
path: foundation/attributescope
---

# AttributeScope

A type that organizes attributes into a grouping, and supports dynamic member lookup and serialization of attribute keys.

## Declaration

```swift
protocol AttributeScope : DecodingConfigurationProviding, EncodingConfigurationProviding, SendableMetatype
```

## Overview

Overview Attribute owners — typically frameworks — define attributes with AttributedStringKey types. To allow access to attributes with dynamic member lookup, owners create one or more structures that conform to AttributeScope. The scopes provide short names for their attributes that map to the AttributedStringKey type. The following example shows how to do this: struct TextStyleAttributes : AttributeScope {     let foregroundColor : ForegroundColorAttribute // ForegroundColorAttribute.Value == Color     let backgroundColor : BackgroundColorAttribute // BackgroundColorAttribute.Value == Color     let underlineStyle : UnderlineStyleAttribute // UnderlineStyleAttribute.Value == UnderlineStyle     // etc. } This allows callers to use a syntax like myAttributedString.foregroundColor = .red.

## Topics

### Supporting Coding Configurations

- [encodingConfiguration](foundation/attributescope/encodingconfiguration.md)
- [decodingConfiguration](foundation/attributescope/decodingconfiguration.md)

### Type Properties

- [attributeKeys](foundation/attributescope/attributekeys.md)

## Relationships

### Inherits From

- [DecodingConfigurationProviding](foundation/decodingconfigurationproviding.md)
- [EncodingConfigurationProviding](foundation/encodingconfigurationproviding.md)
- [SendableMetatype](swift/sendablemetatype.md)

### Conforming Types

- [AttributeScopes.AccessibilityAttributes](foundation/attributescopes/accessibilityattributes.md)
- [AttributeScopes.AppKitAttributes](foundation/attributescopes/appkitattributes.md)
- [AttributeScopes.FoundationAttributes](foundation/attributescopes/foundationattributes.md)
- [AttributeScopes.FoundationAttributes.NumberFormatAttributes](foundation/attributescopes/foundationattributes/numberformatattributes.md)
- [AttributeScopes.SpeechAttributes](foundation/attributescopes/speechattributes.md)
- [AttributeScopes.SwiftUIAttributes](foundation/attributescopes/swiftuiattributes.md)
- [AttributeScopes.TranslationAttributes](foundation/attributescopes/translationattributes.md)
- [AttributeScopes.UIKitAttributes](foundation/attributescopes/uikitattributes.md)
