<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Decimal/FormatStyle/Attributed-swift.struct",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So9NSDecimala10FoundationE11FormatStyleV10AttributedV"
  },
  "title" : "Decimal.FormatStyle.Attributed"
}
-->

# Decimal.FormatStyle.Attributed

A format style that converts integers into attributed strings.

```
struct Attributed
```

## Overview

Use the [`attributed`](/documentation/Foundation/IntegerFormatStyle/attributed-swift.property) modifier on a [`FloatingPointFormatStyle`](/documentation/Foundation/FloatingPointFormatStyle) to create a format style of this type.

The attributed strings that this format style creates contain attributes from the [`AttributeScopes.FoundationAttributes.NumberFormatAttributes`](/documentation/Foundation/AttributeScopes/FoundationAttributes/NumberFormatAttributes) attribute scope. Use these attributes to determine which runs of the attributed string represent different parts of the formatted value.

The following example finds runs of the attributed string that represent different parts of a formatted currency, and adds additional attributes like [`foregroundColor`](/documentation/Foundation/AttributeScopes/SwiftUIAttributes/foregroundColor) and [`inlinePresentationIntent`](/documentation/Foundation/AttributeScopes/FoundationAttributes/inlinePresentationIntent).

```swift
func attributedPrice(price: Decimal) -> AttributedString {
    var attributedPrice = price.formatted(
        .currency(code: "USD")
        .attributed)

    for run in attributedPrice.runs {
        if run.attributes.numberSymbol == .currency ||
            run.attributes.numberSymbol == .decimalSeparator  {
            attributedPrice[run.range].foregroundColor = .red
        }
        if run.attributes.numberPart == .integer ||
            run.attributes.numberPart == .fraction {
            attributedPrice[run.range].inlinePresentationIntent = [.stronglyEmphasized]
        }
    }
    return attributedPrice
}
```

User interface frameworks like SwiftUI can use these attributes when presenting the attributed string, as seen here:

![The currency value $1,234.56, with the dollar sign and decimal separator in red, and the digits in bold.](images/com.apple.foundation/media-4099417@2x.png)

## Topics

### Formatting a decimal value

[`format(_:)`](/documentation/Foundation/Decimal/FormatStyle/Attributed-swift.struct/format(_:))

Formats a decimal value, using this style.

### Modifying the locale

[`locale(_:)`](/documentation/Foundation/Decimal/FormatStyle/Attributed-swift.struct/locale(_:))

Modifies the format style to use the specified locale.

### Applying currency styles

### Applying measurement styles

### Applying list styles

### Supporting types

## Relationships

### Conforms To

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

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

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

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

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

[`FormatStyle`](/documentation/Foundation/FormatStyle)

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

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

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

---

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)