<!--
{
  "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/Measurement/FormatStyle",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation11MeasurementVAASo11NSDimensionCRbzrlE11FormatStyleV"
  },
  "title" : "Measurement.FormatStyle"
}
-->

# Measurement.FormatStyle

A type that provides localized representations of measurements.

```
struct FormatStyle
```

## Overview

A measurement format style creates human-readable text from a [`Measurement`](/documentation/Foundation/Measurement). You can customize the formatting behavior of the format style using the [`width`](/documentation/Foundation/Measurement/FormatStyle/width), `numberFormat`, [`usage`](/documentation/Foundation/Measurement/FormatStyle/usage), and [`locale`](/documentation/Foundation/Measurement/FormatStyle/locale) properties. The system automatically caches unique configurations of [`Measurement.FormatStyle`](/documentation/Foundation/Measurement/FormatStyle) to enhance performance.

Use either the [`formatted()`](/documentation/Foundation/Measurement/formatted()) or the [`formatted(_:)`](/documentation/Foundation/Measurement/formatted(_:)) instance method of [`Measurement`](/documentation/Foundation/Measurement) to create a string representation of a measurement.

The [`formatted()`](/documentation/Foundation/Measurement/formatted()) method generates a string using the default measurement format style.

```swift
let temperature = Measurement<UnitTemperature>(value: 38, unit: .celsius)
temperature.formatted()
// For locale: en_US: 100°F
// For locale: fr_FR: 38°C
```

The default format style in the previous example abbreviates the measurement unit. To customize any of the properties of the formatted measurement, you provide a measurement format style to the [`formatted(_:)`](/documentation/Foundation/Measurement/formatted(_:)) method. For example, to create a string with the full name of the unit, the code might resemble the following:

```swift
temperature.formatted(.measurement(width: .wide))
// For locale: en_US: 100 degrees Fahrenheit
// For locale: fr_FR: 38 degrés Celsius
```

The previous example uses a static factory method to create a measurement format style within the call to the [`formatted(_:)`](/documentation/Foundation/Measurement/formatted(_:)) method. You can also create a measurement format style and pass it to the method, such as in the following example:

```swift
let distance = Measurement<UnitLength>(value: 36, unit: .miles)
let distanceStyle = Measurement<UnitLength>.FormatStyle(width: .wide, usage: .road)
distanceStyle.format(distance)
// for locale: en_US: 36 miles
// for locale: fr_FR: 58 kilomètres
```

After you create an instance of a format style, you can use it to format measurements of the same unit type.

## Topics

### Creating a measurement format style

[`init(width:locale:usage:numberFormatStyle:)`](/documentation/Foundation/Measurement/FormatStyle/init(width:locale:usage:numberFormatStyle:))

Creates an instance using the provided width, locale, usage type, and number format.

[`init(width:locale:usage:hidesScaleName:numberFormatStyle:)`](/documentation/Foundation/Measurement/FormatStyle/init(width:locale:usage:hidesScaleName:numberFormatStyle:))

Creates an instance using the provided width, locale, usage type, number format, and the option to hide the unit name.

### Modifying a measurement format style

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

The width of the measurement unit.

[`Measurement.FormatStyle.UnitWidth`](/documentation/Foundation/Measurement/FormatStyle/UnitWidth)

Specifies the width of the unit, determining the textual representation.

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

The formatting of the measurement value.

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

The intended purpose of the formatted measurement.

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

The visibility of the unit name of a temperature.

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

The locale of the format style.

[`locale(_:)`](/documentation/Foundation/Measurement/FormatStyle/locale(_:))

Modifies the measurement format style to use the specified locale.

### Inspecting a measurement format style

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

The attributed style for the measurement format style.

### Formatting a measurement

[`format(_:)`](/documentation/Foundation/Measurement/FormatStyle/format(_:))

Creates a string representation of a measurement.

### Applying currency styles

### Applying measurement styles

### Applying list styles

### Applying byte count styles

Use this format style when the measurement’s unit type is information storage.

[`Measurement.FormatStyle.ByteCount`](/documentation/Foundation/Measurement/FormatStyle/ByteCount)

A format style that provides string representations of byte counts, expressed as measurements of information storage.

### Supporting Types



---

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)