> For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt.

# direction

APISummary
## Introduction

The `direction` CSS property sets the direction of text. 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).

## Examples

**This is an example below: css-api**

**Entry:** `src/direction`
**Bundle:** `dist/direction.lynx.bundle`

```tsx
import { root, useState } from "@lynx-js/react";
import "./index.scss";

const Direction = () => {
  const [rtl, setRtl] = useState(false);

  const containerStyle = {
    direction: rtl ? "rtl" : "ltr" as "rtl" | "ltr",
  };

  return (
    <>
      <view className="con" bindtap={() => setRtl(!rtl)} style={containerStyle}>
        <text className="intro">rtl|ltr</text>
      </view>
      <text>current: {rtl ? "rtl" : "ltr"}</text>
    </>
  );
};

root.render(<Direction />);

```

v0.11.0



## Syntax

```css
direction: normal;
direction: ltr;
direction: rtl;
```

### Values

- `normal`

  **Default value**.

  The [`text-align:start`](/next/api/css/properties/text-align.md) will align the text according to the direction of text content and the direction of text will be inferred from the text content. All other behaviors are same as `ltr`.

  For example:
  For:

  ```html
  <text> abc 1234 </text>
  ```

  The text will be left aligned. And the direction of the will be left to right.

  For:

  ```html
  <text> العاشر ليونيكود 1234</text>
  ```

  The text will be right aligned. And the direction of the will be right to left.

- `ltr`

  Text direction will be left-to-right, the horizontal logical properties "inline-start"(e.g. margin-inline-start) will be mapped to "left", and "inline-end" will be mapped to "right".

- `rtl`

  Text direction will be right-to-left, the horizontal logical properties "inline-start"(e.g. margin-inline-start) will be mapped to "right", and "inline-end" will be mapped to "left".

- `lynx-rtl` deprecated

  Not recommended. **lynx only, designed for make ltr only pages compatible for rtl**, Text direction will be right-to-left, properties "left", "inline-start" (e.g. margin-left) will be mapped to right, and "right", "inline-end" will be mapped to "left".

## Formal definition

| Initial value | `normal` |
| Applies to | all elements |
| Inherited | yes |
| Animatable |  |


## Formal syntax

```
direction = normal | ltr | rtl
```

## Differences from the Web

- Value `normal`, `lynx-rtl` are introduced to improve page compatibility for `rtl`.

## Compatibility

**Compatibility Table**

**Query:** `css.properties.direction`

[Source](https://github.com/lynx-family/lynx/blob/develop/tools/css_generator/css_defines/130-direction.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| direction | Yes (2.0) | Yes (3.4) | Yes (2.0) | Yes (2.0) | Yes (2.0) | Partial |
| lynx-rtl | Yes (2.0) | Yes (3.4) | Yes (2.0) | Yes (2.0) | Yes (2.0) | Yes |

**`direction`**

**Specifications:**

- **Web — Supported (version unknown):** Partial support; direction:rtl is as powerful as direction:lynx-rtl

**`lynx-rtl`**

<code>lynx-rtl</code>

