<!--
{
  "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" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Text/monospacedDigit()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4TextV15monospacedDigitACyF"
  },
  "title" : "monospacedDigit()"
}
-->

# monospacedDigit()

Modifies the text view’s font to use fixed-width digits, while leaving
other characters proportionally spaced.

```
nonisolated func monospacedDigit() -> Text
```

## Return Value

A text view with a modified font that uses fixed-width
numeric characters, while leaving other characters proportionally
spaced.

## Discussion

This modifier only affects numeric characters, and leaves all other
characters unchanged.

The following example shows the effect of `monospacedDigit()` on a
text view. It arranges two text views in a [`VStack`](/documentation/SwiftUI/VStack), each displaying
a formatted date that contains many instances of the character 1.
The second text view uses the `monospacedDigit()`. Because 1 is
usually a narrow character in proportional fonts, applying the
modifier widens all of the 1s, and the text view as a whole.
The non-digit characters in the text view remain unaffected.

```
let myDate = DateComponents(
    calendar: Calendar(identifier: .gregorian),
    timeZone: TimeZone(identifier: "EST"),
    year: 2011,
    month: 1,
    day: 11,
    hour: 11,
    minute: 11
).date!

var body: some View {
    VStack(alignment: .leading) {
        Text(myDate.formatted(date: .long, time: .complete))
            .font(.system(size: 20))
        Text(myDate.formatted(date: .long, time: .complete))
            .font(.system(size: 20))
            .monospacedDigit()
    }
    .padding()
    .navigationTitle("monospacedDigit() Modifier")
}
```

![Two vertically stacked text views, displaying the date January 11,](images/com.apple.SwiftUI/Text-monospacedDigit-1@2x.png)

If the base font of the text view doesn’t support fixed-width digits,
the font remains unchanged.

---

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)