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
Hidden List Section Separator - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
modifier

Hidden List Section Separator

Sets whether to hide the separator associated with a list section.

ArrangementView - iOS on iPhone Duo - Landscape - Fully Open - Liquid Glass - Light Mode - Preview
initializer

ArrangementView

Creates an arrangement view with a primary and secondary view.

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

TabsPickerStyle

A picker style that presents options as segmented tabs. On macOS, this style produces a segmented picker with a visual treatment that distinguishes tab navigation from value selection. On iOS, tvOS, and visionOS, the visual appearance matches that of the standard standard .segmented style. On all supported platforms, VoiceOver announces options as tabs.

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

MenuPickerStyle

A picker style that presents the options as a menu when the user presses a button, or as a submenu when nested within a larger menu.

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.

Min Max Current Value Gauge - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
initializer

Min Max Current Value Gauge

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

Button Roles - iOS on iPhone - Portrait - Liquid Glass - Light Mode - Preview
style

Button Roles

A value that describes the purpose of a button.

Hidden List Row Separator - iOS on iPhone - Portrait - Flat Design - Light Mode - Preview
modifier

Hidden List Row Separator

Sets the display mode to hidden for the separator associated with this specific row.