Skip to content

Conversation

@mrevanzak
Copy link

Summary

Add textAlign property to VoltraTextStyle type definition, aligning TypeScript types with existing native iOS support.

Changes

  • Added textAlign to the Pick<RNTextStyle, ...> union in VoltraTextStyle

Problem

The native iOS side (JSStyleParser.swift) already supports textAlign for Timer and Text components, mapping values like "center", "right", "end" to SwiftUI's TextAlignment. However, the TypeScript type definition was missing this property, preventing autocomplete and type-checking.

Verification

  • TypeScript compiles without errors
  • Aligns with existing short-name mapping (textAlignta) in data/components.json

@vercel
Copy link

vercel bot commented Jan 17, 2026

@mrevanzak is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

Add textAlign property to VoltraTextStyle type definition, aligning TypeScript types with existing native iOS support for text alignment in Timer and Text components.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@mrevanzak mrevanzak force-pushed the feat/text-align-props branch from d340b2a to 73d7c5d Compare January 17, 2026 00:58
@V3RON
Copy link
Contributor

V3RON commented Jan 17, 2026

This is a bit complicated because Text views in SwiftUI behave differently than elements in web or React Native. They don't expand by default. They simply occupy as much space as their content requires.

multilineTextAlignment only takes effect when there is more than one line of text. To achieve a true CSS text-align equivalent, you would have to modify the frame (e.g., .frame(maxWidth: .infinity, alignment: .trailing)), but that is risky and can break the layout. It is usually better to use layout containers like VStack or HStack to position the text correctly.

We definitely need to include this property in our styles, but perhaps we should rename it to multilineTextAlignment so it’s clear that it isn't a direct equivalent to textAlign?

@mrevanzak
Copy link
Author

This is a bit complicated because Text views in SwiftUI behave differently than elements in web or React Native. They don't expand by default. They simply occupy as much space as their content requires.

multilineTextAlignment only takes effect when there is more than one line of text. To achieve a true CSS text-align equivalent, you would have to modify the frame (e.g., .frame(maxWidth: .infinity, alignment: .trailing)), but that is risky and can break the layout. It is usually better to use layout containers like VStack or HStack to position the text correctly.

We definitely need to include this property in our styles, but perhaps we should rename it to multilineTextAlignment so it’s clear that it isn't a direct equivalent to textAlign?

but it works in my case like textAlign should be :D in my case its only 1 line of text and i can make it right aligned with textAlign: right

@V3RON
Copy link
Contributor

V3RON commented Jan 18, 2026

https://developer.apple.com/documentation/swiftui/view/multilinetextalignment(_:)

The modifier has no effect on a Text view that contains only one line of text, because a text view has a width that exactly matches the width of its widest line. If you want to align an entire text view rather than its contents, set the aligment of its container, like a VStack or a frame that you create with the frame(minWidth:idealWidth:maxWidth:minHeight:idealHeight:maxHeight:alignment:) modifier.

However, it turns out that if you are developing a widget and you use this modifier for a Text initialized with a date or time, it will work.

You can use this modifier to control the alignment of a Text view that you create with the init(_:style:) initializer to display localized dates and times, including when the view uses only a single line, but only when that view appears in a widget.

What’s your use case where it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants