---
title: AttributeContainer.Builder
framework: foundation
role: symbol
role_heading: Structure
path: foundation/attributecontainer/builder
---

# AttributeContainer.Builder

A type that iteratively builds attribute containers by setting attribute values.

## Declaration

```swift
struct Builder<T> where T : AttributedStringKey
```

## Overview

Overview The AttributeContainer.Builder type lets you build AttributeContainer instances by chaining together several attributes in one expression. The following example shows this approach: // An attribute container with the link and backgroundColor attributes. let myContainer = AttributeContainer().link(myURL).backgroundColor(.yellow) The first part of this expression, AttributeContainer().link(URL(myURL)), creates a builder to apply the link attribute to the empty AttributeContainer. The builder’s callAsFunction(_:) returns a new AttributeContainer with this attribute set. Then the backgroundColor(.yellow) creates a second builder to modify the just-returned AttributeContainer by adding the backgroundColor attribute. The result is an AttributeContainer with both attributes set.

## Topics

### Calling Builder Functions

- [callAsFunction(_:)](foundation/attributecontainer/builder/callasfunction(_:).md)

## Relationships

### Conforms To

- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.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)
- [AttributedStringKey](foundation/attributedstringkey.md)
