Skip to content

Commit 13e908b

Browse files
committed
feat: direction rtl and ltl
1 parent 12e4594 commit 13e908b

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

content/guide/styling.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ This list of properties can be set in CSS or through the style property of each
226226
| `border-radius` | `borderRadius` | Sets a border radius to the matched view’s. |
227227
| `box-shadow` | `boxShadow` | Sets a box shadow to the matched view's. |
228228
| `clip-path` | `clipPath` | Sets the clip-path. Supported shapes are circle, ellipse, rect and polygon. You can define your own shape using [clippy](http://bennettfeely.com/clippy/) |
229-
| `color` | `color` | Sets a solid-color value to the matched view’s foreground. |
229+
| `color` | `color` | Sets a solid-color value to the matched view’s foreground.
230+
| `direction` | `direction` | Sets the direction of text, table and grid columns, and horizontal overflow. Use rtl for languages written from right to left (like Hebrew or Arabic), and ltr for those written from left to right (like English and most other languages). |
230231
| `font` | `font` | Sets the font properties (this includes `font-family`, `font-size`, `font-style` and `font-weight`) of the matched view. |
231232
| `font-family` | `fontFamily` | Sets the font family of the matched view. |
232233
| `font-size` | `fontSize` | Sets the font size of the matched view (only supports device-independent units). |
@@ -259,6 +260,39 @@ This list of properties can be set in CSS or through the style property of each
259260
| `width` | `width` | Sets the view width. |
260261
| `z-index` | `zIndex` | Sets the z-index. (On Android API Level 21 and above.) |
261262
263+
## Layout direction (LTR / RTL)
264+
265+
NativeScript now supports an **inherited CSS `direction` property** to force the layout direction of views to either left-to-right (`ltr`) or right-to-left (`rtl`).
266+
267+
```css
268+
/* Apply RTL to the entire app */
269+
.ns-root {
270+
direction: rtl;
271+
}
272+
```
273+
274+
What this does:
275+
276+
- tells NativeScript to use the **platform’s native direction APIs** so you get the OS-level behavior for RTL,
277+
- makes navigation transitions direction-aware (slide, flip, etc.),
278+
- makes default label/text alignment respect the direction,
279+
- enables direction-aware layout for FlexboxLayout on iOS,
280+
- aligns horizontal scroll views to the end in RTL,
281+
- and allows using `start` / `end` values for `horizontalAlignment` to align relative to the current direction.
282+
283+
Android note:
284+
285+
```xml
286+
<!-- App_Resources/Android/src/main/AndroidManifest.xml -->
287+
<application
288+
android:name="com.tns.NativeScriptApplication"
289+
android:supportsRtl="true"
290+
...>
291+
</application>
292+
```
293+
294+
You **must** enable `android:supportsRtl="true"` in the manifest for Android to actually honor RTL. On iOS this is always available.
295+
262296
### Accessing NativeScript View properties with CSS
263297
264298
You can also set NativeScript component properties value that are not part of the CSS specification. For example:

0 commit comments

Comments
 (0)