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

# linear-direction

APISummary
## 介绍

`linear-direction` 定义[线性布局](/next/zh/guide/ui/layout/linear-layout.md)中的元件排列方向（默认为**垂直**布局），该方向作为线性布局的**主轴**，另外一个方向称为**交叉轴**。

请注意，值 `row`、`row-reverse` 受线性布局中的 [`direction`](/next/zh/api/css/properties/direction.md) 影响。例如，如果 `dir` 属性是 `rtl` 或者 `lynx-rtl`，`row` 表示从右到左定向的轴，而 `row-reverse` 表示从左到右。

## 使用示例

**下面是一个示例: css-api**

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

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

const LinearDirection = () => {
  const verticalContainerStyle = {
    display: "linear" as const,
    alignSelf: "center" as const,
    justifyContent: "center" as const,
    linearDirection: "column" as const,
  };

  const horizontalContainerStyle = {
    display: "linear" as const,
    alignSelf: "center" as const,
    justifyContent: "center" as const,
    linearDirection: "row" as const,
  };

  const redBoxStyle = {
    width: "70px",
    height: "70px",
    backgroundColor: "red",
  };

  const yellowBoxStyle = {
    width: "70px",
    height: "70px",
    backgroundColor: "yellow",
  };

  const greenBoxStyle = {
    width: "70px",
    height: "70px",
    backgroundColor: "green",
  };

  const textStyle = {
    fontSize: "50rpx" as const,
    alignSelf: "center" as const,
    fontWeight: "900" as const,
    color: "linear-gradient(120deg,#0095ff 30%,#42d392 100%)" as const,
  };

  return (
    <>
      <text style={textStyle}>linear-direction: column</text>
      <view style={verticalContainerStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
      </view>
      <view style={{ height: "50px" }} />
      <text style={textStyle}>linear-direction: row</text>
      <view style={horizontalContainerStyle}>
        <view style={redBoxStyle} />
        <view style={yellowBoxStyle} />
        <view style={greenBoxStyle} />
      </view>
    </>
  );
};

root.render(<LinearDirection />);

```

v0.11.0



## 语法

```css
linear-direction: column;

/* Like <column>, but reversed */
linear-direction: column-reverse;

linear-direction: row;

/* Like <row>, but reversed */
linear-direction: row-reverse;
```

### 取值

- `column`

  **默认值**。线性布局中的元件按照垂直方向进行布局。主轴的方向为垂直方向。

- `row`

  线性布局中的元件按照水平方向进行布局。主轴的方向为水平方向。

- `column-reverse`

  和 `column` 表现一致，但是置换了主轴起点和主轴终点。

- `row-reverse`

  和 `row` 的表现一致，但是置换了主轴起点和主轴终点。

- `vertical` deprecated

  同 `column`。

- `horizontal` deprecated

  同 `row`。

- `horizontal-reverse` deprecated

  同 `row-reverse`。

- `vertical-reverse` deprecated

  同 `column-reverse`。

## 形式定义

| 初始值 | column |
| 适用元素 | 线性容器 |
| 是否支持继承 | 否 |
| 是否支持动画 |  |


## 形式语法

```
linear-direction = column | row | column-reverse | row-reverse
```

## 与 Web 的区别

- Web 无该样式。

## 兼容性

**Compatibility Table**

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

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| linear-direction | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| support&#95;linear&#95;direction | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | Yes |
| support&#95;linear&#95;direction.nested&#95;value&#95;1 | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | Yes |
| support&#95;linear&#95;direction.nested&#95;value&#95;2 | Yes (2.2) | Yes (3.4) | Yes (2.2) | Yes (2.2) | Yes (2.2) | No |
| support&#95;linear&#95;orientation | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |

**`linear-direction`**

sets how linear items are placed in the linear container defining the main axis and the direction.

**Specifications:**

**`support_linear_direction`**

Support <code>linear-direction</code>

**`support_linear_direction.nested_value_1`**

<code>row</code>, <code>row-reverse</code>, <code>column</code>, <code>column-reverse</code>

**`support_linear_direction.nested_value_2`**

<code>vertical</code>, <code>horizontal</code>, <code>vertical-reverse</code>, <code>horizontal-reverse</code>

**Status:** Deprecated

**`support_linear_orientation`**

Supported <code>linear-orientation</code>

**Status:** Deprecated

