Interactive previews iPhone

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

Platform Compatibility

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

Tags

SwiftUI Code

Docs
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

Explore Other Components

Browse all
Uniform Concentric Rectangle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Uniform Concentric Rectangle

Create a rectangle with the same corner style set on four corners.

Custom Value Label Picker - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Custom Value Label Picker

Creates a picker that generates its label from a localized string key and accepts a custom current value label.

SliderTickContentForEach - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

SliderTickContentForEach

A type of slider content that creates content by iterating over a collection.

Nested Menu - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
content

Nested Menu

A Menu inside a Menu

Toolbar Item Visibility Priority - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
modifier

Toolbar Item Visibility Priority

Defines the visibility priority for a toolbar item.

ViewThatFits Vertical - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
initializer

ViewThatFits Vertical

A view that adapts to the available vertical space by providing the first child view that fits.

Gauge Colors - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

Gauge Colors

Customizing the colors of different styles with minimal effort

WheelDatePickerStyle - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

WheelDatePickerStyle

A date picker style that displays each component as columns in a scrollable wheel