Skip to content

[ui][iOS] Add monospacedDigit modifier#43328

Merged
intergalacticspacehighway merged 3 commits intoexpo:mainfrom
axeelz:monospaced-digit-modifier
Feb 21, 2026
Merged

[ui][iOS] Add monospacedDigit modifier#43328
intergalacticspacehighway merged 3 commits intoexpo:mainfrom
axeelz:monospaced-digit-modifier

Conversation

@axeelz
Copy link
Copy Markdown
Contributor

@axeelz axeelz commented Feb 20, 2026

Why

#43256

This modifier is useful for displaying numbers that change over time (timers, counters, prices) without the text shifting layout, as each digit always takes the same width.

How

Added MonospacedDigitModifier inline in ViewModifierRegistry.swift (following the same pattern as BoldModifier/ItalicModifier), registered it in the modifier registry, added the text modifier case in applyTextModifier, and exported it from the TS modifiers.

Test Plan

I added an example in NCL > Expo UI > Modifiers

image

Checklist

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 20, 2026

Subscribed to pull request

File Patterns Mentions
docs/** @amandeepmittal
packages/expo-ui/** @aleqsio, @behenate, @douglowder

Generated by CodeMention

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Feb 20, 2026
@axeelz axeelz force-pushed the monospaced-digit-modifier branch from ad15cbf to 192c02b Compare February 20, 2026 22:24

internal struct MonospacedDigitModifier: ViewModifier, Record {
func body(content: Content) -> some View {
if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove this check since min version we support is 15.0.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 💯
also removed the @platform 15.0+ comments then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My pleasure, thanks for the review!

case "italic":
return text.italic()
case "monospacedDigit":
if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done 💯

@axeelz axeelz force-pushed the monospaced-digit-modifier branch from 192c02b to f16af7f Compare February 21, 2026 11:10
Copy link
Copy Markdown
Contributor

@intergalacticspacehighway intergalacticspacehighway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One last thing, since a modifier is added we'll need to update the docs with below command.

et gdad -p "expo-ui/swift-ui/modifiers"

I'll add a contribution guide.

@axeelz
Copy link
Copy Markdown
Contributor Author

axeelz commented Feb 21, 2026

LGTM. One last thing, since a modifier is added we'll need to update the docs with below command.

et gdad -p "expo-ui/swift-ui/modifiers"

I'll add a contribution guide.

done :)

i tried before with et generate-docs-api-data -p expo-ui but it generated a lot of unrelated changes, this seems to be better 😄

@intergalacticspacehighway intergalacticspacehighway merged commit 4e6087c into expo:main Feb 21, 2026
14 checks passed
@brentvatne brentvatne added the published Changes from the PR have been published to npm label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants