---
title: Measurement.FormatStyle
framework: foundation
role: symbol
role_heading: Structure
path: foundation/measurement/formatstyle
---

# Measurement.FormatStyle

A type that provides localized representations of measurements.

## Declaration

```swift
struct FormatStyle
```

## Overview

Overview A measurement format style creates human-readable text from a Measurement. You can customize the formatting behavior of the format style using the width, numberFormat, usage, and locale properties. The system automatically caches unique configurations of Measurement.FormatStyle to enhance performance. Use either the formatted() or the formatted(_:) instance method of Measurement to create a string representation of a measurement. The formatted() method generates a string using the default measurement format style. 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(_:) method. For example, to create a string with the full name of the unit, the code might resemble the following: 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(_:) method. You can also create a measurement format style and pass it to the method, such as in the following example: 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:)](foundation/measurement/formatstyle/init(width:locale:usage:numberformatstyle:).md)
- [init(width:locale:usage:hidesScaleName:numberFormatStyle:)](foundation/measurement/formatstyle/init(width:locale:usage:hidesscalename:numberformatstyle:).md)

### Modifying a measurement format style

- [width](foundation/measurement/formatstyle/width.md)
- [Measurement.FormatStyle.UnitWidth](foundation/measurement/formatstyle/unitwidth.md)
- [numberFormatStyle](foundation/measurement/formatstyle/numberformatstyle.md)
- [usage](foundation/measurement/formatstyle/usage.md)
- [hidesScaleName](foundation/measurement/formatstyle/hidesscalename.md)
- [locale](foundation/measurement/formatstyle/locale.md)
- [locale(_:)](foundation/measurement/formatstyle/locale(_:).md)

### Inspecting a measurement format style

- [attributed](foundation/measurement/formatstyle/attributed.md)

### Formatting a measurement

- [format(_:)](foundation/measurement/formatstyle/format(_:).md)

### Applying byte count styles

- [Measurement.FormatStyle.ByteCount](foundation/measurement/formatstyle/bytecount.md)

## Relationships

### Conforms To

- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [FormatStyle](foundation/formatstyle.md)
- [Hashable](swift/hashable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)
