---
title: AttributedStringKey
framework: foundation
role: symbol
role_heading: Protocol
path: foundation/attributedstringkey
---

# AttributedStringKey

A type that defines an attribute’s name and type.

## Declaration

```swift
protocol AttributedStringKey : SendableMetatype
```

## Overview

Overview You don’t instantiate types that conform to this protocol. Rather, dynamic member lookup uses this type as the basis for looking up key paths on AttributedString subtypes when using an AttributeScope type parameter. When it also conforms to CodableAttributedStringKey, (or DecodableAttributedStringKey/EncodableAttributedStringKey if the type isn’t fully codable), the AttributedStringKey describes which attributes of an AttributedString support encoding or decoding. Attribute owners — typically frameworks — declare a key like the following: enum OutlineColorAttribute : AttributedStringKey {     typealias Value = Color     static let name = "OutlineColor" } Callers can use these types to get attribute values from attributed strings, but typically you want to reference them by name. Attribute owners enable this by creating one or more structures that conform to AttributeScope, in which they provide short names for their attributes that map to the AttributedStringKey type. The following example shows how to do this: struct MyTextStyleAttributes : AttributeScope {     let outlineColor : OutlineColorAttribute // OutlineColorAttribute.Value == Color     let shadowColor : ShadowColorAttribute // ShadowColorAttribute.Value == Color     // etc. } After you extend AttributeScope like this, extend AttributeDynamicLookup to allow callers to use dynamic member lookup syntax, like myAttributedString.outlineColor = .red.

## Topics

### Delcaring Key Properties

- [name](foundation/attributedstringkey/name.md)
- [Value](foundation/attributedstringkey/value.md)

### Describing the Key

- [description](foundation/attributedstringkey/description.md)

### Type Properties

- [inheritedByAddedText](foundation/attributedstringkey/inheritedbyaddedtext.md)
- [invalidationConditions](foundation/attributedstringkey/invalidationconditions.md)
- [runBoundaries](foundation/attributedstringkey/runboundaries.md)

## Relationships

### Inherits From

- [SendableMetatype](swift/sendablemetatype.md)

### Inherited By

- [DecodableAttributedStringKey](foundation/decodableattributedstringkey.md)
- [EncodableAttributedStringKey](foundation/encodableattributedstringkey.md)
- [MarkdownDecodableAttributedStringKey](foundation/markdowndecodableattributedstringkey.md)
- [ObjectiveCConvertibleAttributedStringKey](foundation/objectivecconvertibleattributedstringkey.md)

### Conforming Types

- [AttributeScopes.AccessibilityAttributes.AdjustedPitchAttribute](foundation/attributescopes/accessibilityattributes/adjustedpitchattribute.md)
- [AttributeScopes.AccessibilityAttributes.AnnouncementPriorityAttribute](foundation/attributescopes/accessibilityattributes/announcementpriorityattribute.md)
- [AttributeScopes.AccessibilityAttributes.HeadingLevelAttribute](foundation/attributescopes/accessibilityattributes/headinglevelattribute.md)
- [AttributeScopes.AccessibilityAttributes.IPANotationAttribute](foundation/attributescopes/accessibilityattributes/ipanotationattribute.md)
- [AttributeScopes.AccessibilityAttributes.IncludesPunctuationAttribute](foundation/attributescopes/accessibilityattributes/includespunctuationattribute.md)
- [AttributeScopes.AccessibilityAttributes.QueueAnnouncementAttribute](foundation/attributescopes/accessibilityattributes/queueannouncementattribute.md)
- [AttributeScopes.AccessibilityAttributes.SpellOutAttribute](foundation/attributescopes/accessibilityattributes/spelloutattribute.md)
- [AttributeScopes.AccessibilityAttributes.TextCustomAttribute](foundation/attributescopes/accessibilityattributes/textcustomattribute.md)
- [AttributeScopes.AccessibilityAttributes.TextualContextAttribute](foundation/attributescopes/accessibilityattributes/textualcontextattribute.md)
- [AttributeScopes.AppKitAttributes.AdaptiveImageGlyphAttribute](foundation/attributescopes/appkitattributes/adaptiveimageglyphattribute.md)
- [AttributeScopes.AppKitAttributes.AttachmentAttribute](foundation/attributescopes/appkitattributes/attachmentattribute.md)
- [AttributeScopes.AppKitAttributes.BackgroundColorAttribute](foundation/attributescopes/appkitattributes/backgroundcolorattribute.md)
- [AttributeScopes.AppKitAttributes.BaselineOffsetAttribute](foundation/attributescopes/appkitattributes/baselineoffsetattribute.md)
- [AttributeScopes.AppKitAttributes.CursorAttribute](foundation/attributescopes/appkitattributes/cursorattribute.md)
- [AttributeScopes.AppKitAttributes.ExpansionAttribute](foundation/attributescopes/appkitattributes/expansionattribute.md)
- [AttributeScopes.AppKitAttributes.FontAttribute](foundation/attributescopes/appkitattributes/fontattribute.md)
- [AttributeScopes.AppKitAttributes.ForegroundColorAttribute](foundation/attributescopes/appkitattributes/foregroundcolorattribute.md)
- [AttributeScopes.AppKitAttributes.GlyphInfoAttribute](foundation/attributescopes/appkitattributes/glyphinfoattribute.md)
- [AttributeScopes.AppKitAttributes.KernAttribute](foundation/attributescopes/appkitattributes/kernattribute.md)
- [AttributeScopes.AppKitAttributes.LigatureAttribute](foundation/attributescopes/appkitattributes/ligatureattribute.md)
- [AttributeScopes.AppKitAttributes.MarkedClauseSegmentAttribute](foundation/attributescopes/appkitattributes/markedclausesegmentattribute.md)
- [AttributeScopes.AppKitAttributes.ObliquenessAttribute](foundation/attributescopes/appkitattributes/obliquenessattribute.md)
- [AttributeScopes.AppKitAttributes.ParagraphStyleAttribute](foundation/attributescopes/appkitattributes/paragraphstyleattribute.md)
- [AttributeScopes.AppKitAttributes.ShadowAttribute](foundation/attributescopes/appkitattributes/shadowattribute.md)
- [AttributeScopes.AppKitAttributes.StrikethroughColorAttribute](foundation/attributescopes/appkitattributes/strikethroughcolorattribute.md)
- [AttributeScopes.AppKitAttributes.StrikethroughStyleAttribute](foundation/attributescopes/appkitattributes/strikethroughstyleattribute.md)
- [AttributeScopes.AppKitAttributes.StrokeColorAttribute](foundation/attributescopes/appkitattributes/strokecolorattribute.md)
- [AttributeScopes.AppKitAttributes.StrokeWidthAttribute](foundation/attributescopes/appkitattributes/strokewidthattribute.md)
- [AttributeScopes.AppKitAttributes.SuperscriptAttribute](foundation/attributescopes/appkitattributes/superscriptattribute.md)
- [AttributeScopes.AppKitAttributes.TextAlternativesAttribute](foundation/attributescopes/appkitattributes/textalternativesattribute.md)
- [AttributeScopes.AppKitAttributes.TextEffectAttribute](foundation/attributescopes/appkitattributes/texteffectattribute.md)
- [AttributeScopes.AppKitAttributes.ToolTipAttribute](foundation/attributescopes/appkitattributes/tooltipattribute.md)
- [AttributeScopes.AppKitAttributes.TrackingAttribute](foundation/attributescopes/appkitattributes/trackingattribute.md)
- [AttributeScopes.AppKitAttributes.UnderlineColorAttribute](foundation/attributescopes/appkitattributes/underlinecolorattribute.md)
- [AttributeScopes.AppKitAttributes.UnderlineStyleAttribute](foundation/attributescopes/appkitattributes/underlinestyleattribute.md)
- [AttributeScopes.CoreTextAttributes.LineHeightAttribute](foundation/attributescopes/coretextattributes/lineheightattribute.md)
- [AttributeScopes.CoreTextAttributes.TextAlignmentAttribute](foundation/attributescopes/coretextattributes/textalignmentattribute.md)
- [AttributeScopes.FoundationAttributes.AgreementArgumentAttribute](foundation/attributescopes/foundationattributes/agreementargumentattribute.md)
- [AttributeScopes.FoundationAttributes.AgreementConceptAttribute](foundation/attributescopes/foundationattributes/agreementconceptattribute.md)
- [AttributeScopes.FoundationAttributes.AlternateDescriptionAttribute](foundation/attributescopes/foundationattributes/alternatedescriptionattribute.md)
- [AttributeScopes.FoundationAttributes.ByteCountAttribute](foundation/attributescopes/foundationattributes/bytecountattribute.md)
- [AttributeScopes.FoundationAttributes.DateFieldAttribute](foundation/attributescopes/foundationattributes/datefieldattribute.md)
- [AttributeScopes.FoundationAttributes.DurationFieldAttribute](foundation/attributescopes/foundationattributes/durationfieldattribute.md)
- [AttributeScopes.FoundationAttributes.ImageURLAttribute](foundation/attributescopes/foundationattributes/imageurlattribute.md)
- [AttributeScopes.FoundationAttributes.InflectionAlternativeAttribute](foundation/attributescopes/foundationattributes/inflectionalternativeattribute.md)
- [AttributeScopes.FoundationAttributes.InflectionRuleAttribute](foundation/attributescopes/foundationattributes/inflectionruleattribute.md)
- [AttributeScopes.FoundationAttributes.InlinePresentationIntentAttribute](foundation/attributescopes/foundationattributes/inlinepresentationintentattribute.md)
- [AttributeScopes.FoundationAttributes.LanguageIdentifierAttribute](foundation/attributescopes/foundationattributes/languageidentifierattribute.md)
- [AttributeScopes.FoundationAttributes.LinkAttribute](foundation/attributescopes/foundationattributes/linkattribute.md)
- [AttributeScopes.FoundationAttributes.ListItemDelimiterAttribute](foundation/attributescopes/foundationattributes/listitemdelimiterattribute.md)
- [AttributeScopes.FoundationAttributes.LocalizedNumberFormatAttribute](foundation/attributescopes/foundationattributes/localizednumberformatattribute.md)
- [AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes.LocalizedDateArgumentAttribute](foundation/attributescopes/foundationattributes/localizedstringargumentattributes-swift.struct/localizeddateargumentattribute.md)
- [AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes.LocalizedDateIntervalArgumentAttribute](foundation/attributescopes/foundationattributes/localizedstringargumentattributes-swift.struct/localizeddateintervalargumentattribute.md)
- [AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes.LocalizedNumericArgumentAttribute](foundation/attributescopes/foundationattributes/localizedstringargumentattributes-swift.struct/localizednumericargumentattribute.md)
- [AttributeScopes.FoundationAttributes.LocalizedStringArgumentAttributes.LocalizedURLArgumentAttribute](foundation/attributescopes/foundationattributes/localizedstringargumentattributes-swift.struct/localizedurlargumentattribute.md)
- [AttributeScopes.FoundationAttributes.MarkdownSourcePositionAttribute](foundation/attributescopes/foundationattributes/markdownsourcepositionattribute.md)
- [AttributeScopes.FoundationAttributes.MeasurementAttribute](foundation/attributescopes/foundationattributes/measurementattribute.md)
- [AttributeScopes.FoundationAttributes.MorphologyAttribute](foundation/attributescopes/foundationattributes/morphologyattribute.md)
- [AttributeScopes.FoundationAttributes.NumberFormatAttributes.NumberPartAttribute](foundation/attributescopes/foundationattributes/numberformatattributes/numberpartattribute.md)
- [AttributeScopes.FoundationAttributes.NumberFormatAttributes.SymbolAttribute](foundation/attributescopes/foundationattributes/numberformatattributes/symbolattribute.md)
- [AttributeScopes.FoundationAttributes.PersonNameComponentAttribute](foundation/attributescopes/foundationattributes/personnamecomponentattribute.md)
- [AttributeScopes.FoundationAttributes.PresentationIntentAttribute](foundation/attributescopes/foundationattributes/presentationintentattribute.md)
- [AttributeScopes.FoundationAttributes.ReferentConceptAttribute](foundation/attributescopes/foundationattributes/referentconceptattribute.md)
- [AttributeScopes.FoundationAttributes.ReplacementIndexAttribute](foundation/attributescopes/foundationattributes/replacementindexattribute.md)
- [AttributeScopes.FoundationAttributes.WritingDirectionAttribute](foundation/attributescopes/foundationattributes/writingdirectionattribute.md)
- [AttributeScopes.SpeechAttributes.ConfidenceAttribute](foundation/attributescopes/speechattributes/confidenceattribute.md)
- [AttributeScopes.SpeechAttributes.TimeRangeAttribute](foundation/attributescopes/speechattributes/timerangeattribute.md)
- [AttributeScopes.SwiftUIAttributes.AdaptiveImageGlyphAttribute](foundation/attributescopes/swiftuiattributes/adaptiveimageglyphattribute.md)
- [AttributeScopes.SwiftUIAttributes.BackgroundColorAttribute](foundation/attributescopes/swiftuiattributes/backgroundcolorattribute.md)
- [AttributeScopes.SwiftUIAttributes.BaselineOffsetAttribute](foundation/attributescopes/swiftuiattributes/baselineoffsetattribute.md)
- [AttributeScopes.SwiftUIAttributes.FontAttribute](foundation/attributescopes/swiftuiattributes/fontattribute.md)
- [AttributeScopes.SwiftUIAttributes.ForegroundColorAttribute](foundation/attributescopes/swiftuiattributes/foregroundcolorattribute.md)
- [AttributeScopes.SwiftUIAttributes.KerningAttribute](foundation/attributescopes/swiftuiattributes/kerningattribute.md)
- [AttributeScopes.SwiftUIAttributes.StrikethroughStyleAttribute](foundation/attributescopes/swiftuiattributes/strikethroughstyleattribute.md)
- [AttributeScopes.SwiftUIAttributes.TrackingAttribute](foundation/attributescopes/swiftuiattributes/trackingattribute.md)
- [AttributeScopes.SwiftUIAttributes.UnderlineStyleAttribute](foundation/attributescopes/swiftuiattributes/underlinestyleattribute.md)
- [AttributeScopes.TranslationAttributes.SkipTranslationAttribute](foundation/attributescopes/translationattributes/skiptranslationattribute.md)
- [AttributeScopes.UIKitAttributes.AdaptiveImageGlyphAttribute](foundation/attributescopes/uikitattributes/adaptiveimageglyphattribute.md)
- [AttributeScopes.UIKitAttributes.AttachmentAttribute](foundation/attributescopes/uikitattributes/attachmentattribute.md)
- [AttributeScopes.UIKitAttributes.BackgroundColorAttribute](foundation/attributescopes/uikitattributes/backgroundcolorattribute.md)
- [AttributeScopes.UIKitAttributes.BaselineOffsetAttribute](foundation/attributescopes/uikitattributes/baselineoffsetattribute.md)
- [AttributeScopes.UIKitAttributes.ExpansionAttribute](foundation/attributescopes/uikitattributes/expansionattribute.md)
- [AttributeScopes.UIKitAttributes.FontAttribute](foundation/attributescopes/uikitattributes/fontattribute.md)
- [AttributeScopes.UIKitAttributes.ForegroundColorAttribute](foundation/attributescopes/uikitattributes/foregroundcolorattribute.md)
- [AttributeScopes.UIKitAttributes.KernAttribute](foundation/attributescopes/uikitattributes/kernattribute.md)
- [AttributeScopes.UIKitAttributes.LigatureAttribute](foundation/attributescopes/uikitattributes/ligatureattribute.md)
- [AttributeScopes.UIKitAttributes.ObliquenessAttribute](foundation/attributescopes/uikitattributes/obliquenessattribute.md)
- [AttributeScopes.UIKitAttributes.ParagraphStyleAttribute](foundation/attributescopes/uikitattributes/paragraphstyleattribute.md)
- [AttributeScopes.UIKitAttributes.ShadowAttribute](foundation/attributescopes/uikitattributes/shadowattribute.md)
- [AttributeScopes.UIKitAttributes.StrikethroughColorAttribute](foundation/attributescopes/uikitattributes/strikethroughcolorattribute.md)
- [AttributeScopes.UIKitAttributes.StrikethroughStyleAttribute](foundation/attributescopes/uikitattributes/strikethroughstyleattribute.md)
- [AttributeScopes.UIKitAttributes.StrokeColorAttribute](foundation/attributescopes/uikitattributes/strokecolorattribute.md)
- [AttributeScopes.UIKitAttributes.StrokeWidthAttribute](foundation/attributescopes/uikitattributes/strokewidthattribute.md)
- [AttributeScopes.UIKitAttributes.TextEffectAttribute](foundation/attributescopes/uikitattributes/texteffectattribute.md)
- [AttributeScopes.UIKitAttributes.TextItemTagAttribute](foundation/attributescopes/uikitattributes/textitemtagattribute.md)
- [AttributeScopes.UIKitAttributes.TrackingAttribute](foundation/attributescopes/uikitattributes/trackingattribute.md)
- [AttributeScopes.UIKitAttributes.UnderlineColorAttribute](foundation/attributescopes/uikitattributes/underlinecolorattribute.md)
- [AttributeScopes.UIKitAttributes.UnderlineStyleAttribute](foundation/attributescopes/uikitattributes/underlinestyleattribute.md)

## See Also

### Accessing Attributes

- [subscript(_:)](foundation/attributecontainer/subscript(_:).md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-657oj.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-3jcvx.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-60ps5.md)
- [subscript(dynamicMember:)](foundation/attributecontainer/subscript(dynamicmember:)-swift.type.subscript.md)
- [AttributeContainer.Builder](foundation/attributecontainer/builder.md)
