---
title: "Text Format | Explore SwiftUI"
description: "Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style"
canonical_url: "https://exploreswiftui.com/library/text/text-format"
meta:
  author: "Explore SwiftUI"
  "og:description": "Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style"
  "og:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Text%2BFormat%2Cdescription_Creates%2Ba%2Btext%2Bview%2Bthat%2Bdisplays%2Bthe%2Bformatted%2Brepresentation%2Bof%2Ba%2Bnonstring%2Btype%2Bsupported%2Bby%2Ba%2Bcorresponding%2Bformat%2Bstyle.%2Ccategory_Text%2Cimage_~L2FwaS9pbWFnZXMvOTkvdmFyaWFudHMvMzA3P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L3RleHQvdGV4dC1mb3JtYXQi%2Cs_quXj8CbXalWuaiP9.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Text Format | Explore SwiftUI"
  "twitter:description": "Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style"
  "twitter:image": "https://exploreswiftui.com/_og/d/c_Component%2Ctitle_Text%2BFormat%2Cdescription_Creates%2Ba%2Btext%2Bview%2Bthat%2Bdisplays%2Bthe%2Bformatted%2Brepresentation%2Bof%2Ba%2Bnonstring%2Btype%2Bsupported%2Bby%2Ba%2Bcorresponding%2Bformat%2Bstyle.%2Ccategory_Text%2Cimage_~L2FwaS9pbWFnZXMvOTkvdmFyaWFudHMvMzA3P3Y9MTc5MDA3MzQ3ODg0MiZyPTImdz0xMjgwJnE9ODUmZj1qcGVn%2CimageMode_crop%2CimagePosition_center%2CimageFrame_~cG9zaXRpb246IGFic29sdXRlOyByaWdodDogMDsgd2lkdGg6IDY0MHB4OyBoZWlnaHQ6IDQ4MHB4OyBkaXNwbGF5OiBmbGV4OyBvdmVyZmxvdzogaGlkZGVuOyBiYWNrZ3JvdW5kOiAjRkZGRkZGOyBib3gtc2hhZG93OiAwIC0xMHB4IDUwcHggcmdiYSgzNyw5OSwyMzUsMC4xOCk7IGJvcmRlci1sZWZ0OiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgdG9wOiA3NXB4OyBib3JkZXItdG9wOiAxcHggc29saWQgcmdiYSgwLDAsMCwwLjA2KTsgYm9yZGVyLWJvdHRvbTogMXB4IHNvbGlkIHJnYmEoMCwwLDAsMC4wNik7IGJvcmRlci10b3AtbGVmdC1yYWRpdXM6IDMycHg7IGJvcmRlci1ib3R0b20tbGVmdC1yYWRpdXM6IDMycHg7%2Cprops_eyJwbGF0Zm9ybXMiOlsiaU9TIiwiaVBhZE9TIiwibWFjT1MiLCJ3YXRjaE9TIiwidHZPUyIsInZpc2lvbk9TIl19%2Cp_Ii9saWJyYXJ5L3RleHQvdGV4dC1mb3JtYXQi%2Cs_quXj8CbXalWuaiP9.png"
  "twitter:title": "Text Format | Explore SwiftUI"
---

> Index of every page on this site: [llms.txt](https://exploreswiftui.com/llms.txt)

**Interactive previews**[ iPhone](https://exploreswiftui.com/iphone?element=99)

# **Text Format**

Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style.

![Text Format - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/99/variants/307?v=1790073478842&r=2&w=800&q=80&f=webp)

### **Platform Compatibility**

iOS 18.0+ iPadOS 18.0+ macOS 15.0+ watchOS 11.0+ tvOS 18.0+ visionOS 2.0+

### **Tags**

### **SwiftUI Code**

[ Docs](<https://developer.apple.com/documentation/swiftui/text/init(_:format:)>)

```
VStack {
  HStack {
    Text(1234.56, format: .currency(code: Locale.current.currency?.identifier ?? "USD"))
    Text(0.874, format: .percent)
    Text(3.14159, format: .number.precision(.fractionLength(2)))
    Text(9876543, format: .number.grouping(.automatic))
    Text(6.022e23, format: .number.notation(.scientific))
  }
  HStack {
    Text(Measurement(value: 123.45, unit: UnitLength.meters), format: .measurement(width: .wide))
    Text(Measurement(value: 70.0, unit: UnitMass.kilograms), format: .measurement(width: .narrow))
    Text(Measurement(value: 25.5, unit: UnitTemperature.celsius), format: .measurement(width: .abbreviated))
    Text(Measurement(value: -30.1, unit: UnitTemperature.celsius), format: .measurement(width: .wide))
  }
  HStack {
    Text(Date(), format: .dateTime.hour().minute().second())
    Text(Date(), format: .dateTime.day().month().year())

    Text(Duration.seconds(3800), format: .time(pattern: .hourMinute))
    Text(Duration.seconds(91), format: .time(pattern: .minuteSecond))
  }
}
```

### **Found an issue or have a suggestion?**

Created: July 21, 2025Updated: July 21, 2025

![Connect Wizard](https://exploreswiftui.com/_ipx/f_webp&q_80&s_48x48/images/connect-wizard-icon.png)

**Connect Wizard**

**Unlock insights App Store Connect doesn’t show you.**

[** Get Started **](https://apps.apple.com/app/apple-store/id6747314580?pt=121213751&ct=Explore%20SwiftUI%20Banner&mt=8)

### **Explore Other Components **

[**Browse all **](https://exploreswiftui.com/)

![Min Max Current Value Gauge - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/40/variants/231?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Min Max Current Value Gauge**

Creates a gauge showing a value within a range and describes the gauge’s current, minimum, and maximum values

![List Row Spacing - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview](https://exploreswiftui.com/api/images/112/variants/31?v=1790073478842&r=2&w=412&q=75&f=webp)

### **List Row Spacing**

Sets the vertical spacing between two adjacent rows in a List.

![Sheet Drag Indicator Visibility - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/138/variants/428?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Sheet Drag Indicator Visibility**

Sets the visibility of the drag indicator on top of a sheet.

![Hide Tab Bar On Scroll Down - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/88/variants/383?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Hide Tab Bar On Scroll Down**

Minimize the tab bar when downwards scrolling starts. Minimizing is supported for tab bars on only iPhone

![Formatted Labeled Content - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/151/variants/490?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Formatted Labeled Content**

Creates a labeled informational view from a formatted value.

![Tab View Side Bar Header - iPadOS - Landscape - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/167/variants/729?v=1790073478842&r=2&w=412&q=75&f=webp)

### **Tab View Side Bar Header**

Adds a custom header to the sidebar of a tab view.

![AccessoryCircularGaugeStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/41/variants/219?v=1790073478842&r=2&w=412&q=75&f=webp)

### **AccessoryCircularGaugeStyle**

A gauge style that displays an open ring with a marker that appears at a point along the ring to indicate the gauge’s current value

![Sheet Placement - iOS on iPhone Duo - Landscape - Fully Open - Liquid Glass - Light Mode - Preview](https://exploreswiftui.com/api/images/231/variants/1889?v=1790591163840&r=2&w=412&q=75&f=webp)

### **Sheet Placement**

Sets the placement of a presentation within the presenting view. This may fall back to center on small screens.

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://exploreswiftui.com/#website","@type":"WebSite","description":"A visual library for SwiftUI APIs, components, and modifiers","inLanguage":"en-US","name":"Explore SwiftUI","url":"https://exploreswiftui.com/","publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/text/text-format#webpage","@type":"WebPage","dateModified":"2025-07-21T15:39:55.400Z","datePublished":"2025-07-21T15:21:49.606Z","description":"Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style","name":"Text Format","url":"https://exploreswiftui.com/library/text/text-format","breadcrumb":{"@id":"https://exploreswiftui.com/library/text/text-format#breadcrumb"},"isPartOf":{"@id":"https://exploreswiftui.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://exploreswiftui.com/library/text/text-format"]}],"primaryImageOfPage":{"@id":"https://exploreswiftui.com/#logo"}},{"@id":"https://exploreswiftui.com/#identity","@type":"Organization","description":"A visual library for SwiftUI APIs, components, and modifiers","name":"Explore SwiftUI","url":"https://exploreswiftui.com","logo":{"@id":"https://exploreswiftui.com/#logo"},"sameAs":["https://x.com/Typ0genius","https://mastodon.social/@Typ0genius"]},{"@id":"https://exploreswiftui.com/library/text/text-format#article","dateModified":"2025-07-21T15:39:55.400Z","datePublished":"2025-07-21T15:21:49.606Z","description":"Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style","headline":"Text Format","inLanguage":"en-US","name":"Text Format","thumbnailUrl":"https://exploreswiftui.com/api/images/99/variants/307?v=1790073478842&r=2","url":"https://exploreswiftui.com/library/text/text-format","@type":["Article","TechArticle"],"about":{"@type":"Thing","name":"SwiftUI"},"author":{"@id":"https://exploreswiftui.com/#identity"},"image":{"@id":"https://exploreswiftui.com/#/schema/image/1"},"isPartOf":{"@type":"WebSite","name":"Explore SwiftUI","url":"https://exploreswiftui.com"},"mainEntityOfPage":{"@id":"https://exploreswiftui.com/library/text/text-format#webpage"},"publisher":{"@id":"https://exploreswiftui.com/#identity"}},{"@id":"https://exploreswiftui.com/library/text/text-format#/schema/software-source-code/1","@type":"SoftwareSourceCode","codeRepository":"https://developer.apple.com/documentation/swiftui/text/init(_:format:)","codeSampleType":"full example","description":"Creates a text view that displays the formatted representation of a nonstring type supported by a corresponding format style","name":"Text Format SwiftUI Example","programmingLanguage":"Swift","runtimePlatform":"SwiftUI","text":"VStack {\n  HStack {\n    Text(1234.56, format: .currency(code: Locale.current.currency?.identifier ?? \"USD\"))\n    Text(0.874, format: .percent)\n    Text(3.14159, format: .number.precision(.fractionLength(2)))\n    Text(9876543, format: .number.grouping(.automatic))\n    Text(6.022e23, format: .number.notation(.scientific))\n  }\n  HStack {\n    Text(Measurement(value: 123.45, unit: UnitLength.meters), format: .measurement(width: .wide))\n    Text(Measurement(value: 70.0, unit: UnitMass.kilograms), format: .measurement(width: .narrow))\n    Text(Measurement(value: 25.5, unit: UnitTemperature.celsius), format: .measurement(width: .abbreviated))\n    Text(Measurement(value: -30.1, unit: UnitTemperature.celsius), format: .measurement(width: .wide))\n  }\n  HStack {\n    Text(Date(), format: .dateTime.hour().minute().second())\n    Text(Date(), format: .dateTime.day().month().year())\n\n    Text(Duration.seconds(3800), format: .time(pattern: .hourMinute))\n    Text(Duration.seconds(91), format: .time(pattern: .minuteSecond))\n  }\n}","about":[{"@type":"Thing","name":"SwiftUI"},{"@type":"Thing","name":"Text"},{"@type":"Thing","name":"Text Format"}]},{"@id":"https://exploreswiftui.com/library/text/text-format#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://exploreswiftui.com","position":1},{"@type":"ListItem","name":"Text","item":"https://exploreswiftui.com/library/text","position":2},{"@type":"ListItem","name":"Text Format","item":"https://exploreswiftui.com/library/text/text-format","position":3}]},{"@id":"https://exploreswiftui.com/#logo","@type":"ImageObject","caption":"Explore SwiftUI","contentUrl":"https://exploreswiftui.com/apple-touch-icon.png","inLanguage":"en","url":"https://exploreswiftui.com/apple-touch-icon.png"},{"@id":"https://exploreswiftui.com/#/schema/image/1","@type":"ImageObject","contentUrl":"https://exploreswiftui.com/api/images/99/variants/307?v=1790073478842&r=2","inLanguage":"en","url":"https://exploreswiftui.com/api/images/99/variants/307?v=1790073478842&r=2"}]}
```