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

# deprecated linear-gravity

APISummary
:::warning
This API is deprecated.
:::

## Introduction

The CSS `linear-gravity` property defines how distributes space between and around content items along the main-axis of a [linear](/next/guide/ui/layout/linear-layout.md) container. Similar to [flexible box layout](/next/guide/ui/layout/flexible-box-layout.md) [`justify-content`](/next/api/css/properties/justify-content.md).

:::info
When using `justify-content` and `linear-gravity` both, `linear-gravity` will override `justify-content`.
:::

## Examples

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

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

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

const LinearGravity = () => {
  const [linearDirection, setLinearDirection] = useState(false);
  const container1Style = {
    linearDirection: linearDirection ? "row" : "column" as "row" | "column",
    linearGravity: "none" as const,
  };
  const container2Style = {
    linearDirection: linearDirection ? "row" : "column" as "row" | "column",
    linearGravity: "start" as const,
  };
  const container3Style = {
    linearDirection: linearDirection ? "row" : "column" as "row" | "column",
    linearGravity: "end" as const,
  };
  const container4Style = {
    linearDirection: linearDirection ? "row" : "column" as "row" | "column",
    linearGravity: "center" as const,
  };
  const container5Style = {
    linearDirection: linearDirection ? "row" : "column" as "row" | "column",
    linearGravity: "space-between" as const,
  };
  const buttonStyle = {
    width: "20%",
    height: "50px",
    backgroundColor: "red" as const,
  };
  const text1Style = {
    fontSize: "40rpx" as const,
    marginRight: "12rpx",
    fontWeight: "900" as const,
    color: "linear-gradient(120deg ,#0095ff 30% ,#42d392 100%)" as const,
  };
  const text2Style = {
    fontSize: "50rpx" as const,
    alignSelf: "center" as const,
    fontWeight: "900" as const,
    color: "linear-gradient(120deg,#0095ff 30%,#42d392 100%)" as const,
  };
  const view1Style = {
    width: "20px",
    height: "20px",
    backgroundColor: "red" as const,
  };
  const view2Style = {
    width: "20px",
    height: "20px",
    backgroundColor: "yellow" as const,
  };
  const view3Style = {
    width: "20px",
    height: "20px",
    backgroundColor: "green" as const,
  };

  return (
    <scroll-view className="root" scroll-orientation="vertical">
      <view style={buttonStyle} bindtap={() => setLinearDirection(!linearDirection)}></view>
      <text style={text1Style}>Click above red button to switch linear-direction</text>
      <text style={text2Style}>Current: "{linearDirection ? "row" : "column"}"</text>
      <text className="title">linear-gravity:none;(default)</text>
      <view className="linear_container" style={container1Style}>
        <view style={view1Style}></view>
        <view style={view2Style}></view>
        <view style={view3Style}></view>
      </view>
      <text className="title">linear-gravity:start;</text>
      <view className="linear_container" style={container2Style}>
        <view style={view1Style}></view>
        <view style={view2Style}></view>
        <view style={view3Style}></view>
      </view>
      <text className="title">linear-gravity:end;</text>
      <view className="linear_container" style={container3Style}>
        <view style={view1Style}></view>
        <view style={view2Style}></view>
        <view style={view3Style}></view>
      </view>
      <text className="title">linear-gravity:center;</text>
      <view className="linear_container" style={container4Style}>
        <view style={view1Style}></view>
        <view style={view2Style}></view>
        <view style={view3Style}></view>
      </view>
      <text className="title">linear-gravity:space-between;</text>
      <view className="linear_container" style={container5Style}>
        <view style={view1Style}></view>
        <view style={view2Style}></view>
        <view style={view3Style}></view>
      </view>
    </scroll-view>
  );
};

root.render(<LinearGravity />);

```

v0.11.0



## Syntax

```css
linear-gravity: none;
linear-gravity: start;
linear-gravity: end;
linear-gravity: center;
linear-gravity: space-between;
```

### Values

- `none`

  **Default value**. It is equivalent to `start`.

- `start`

  Align the beginning of the parent element main axis.

- `end`

  Align the end of the parent element main axis.

- `center`

  Align the center of the parent element's main axis.

- `space-between`

In the corresponding layout direction, the two ends are aligned and the middle interval is equal.

- `top` deprecated

  Not recommended, it is recommended to use `start`. Align up, vertical layout takes effect.

- `bottom` deprecated

  Not recommended, it is recommended to use `end`. Align down, vertical layout takes effect.

- `left` deprecated

  Not recommended, it is recommended to use `start`. Align left, horizontal layout takes effect.

- `right` deprecated

  Not recommended, it is recommended to use `end`. Align right, horizontal layout takes effect.

- `center-vertical` deprecated

  Not recommended, it is recommended to use `center`. Centered vertically, vertical layout takes effect.

- `center-horizontal` deprecated

  Not recommended, it is recommended to use `center`. Centered horizontally, horizontal layout takes effect.

## Formal definition

| Initial value | none |
| Applies to | linear containers |
| Inherited | no |
| Animatable |  |


## Formal syntax

```
linear-gravity = none | start | end | center | space-between
```

## Differences from the Web

- No such style in Web.

## Compatibility

**Compatibility Table**

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

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

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| linear-gravity | Yes (1.0) | Yes (3.4) | Yes (1.0) | Yes (1.0) | Yes (1.0) | Yes |
| value1 | Yes (1.6) | Yes (3.4) | Yes (1.6) | Yes (1.6) | Yes (1.6) | Yes |

**`linear-gravity`**

defines how distributes space between and around content items along the main-axis of a linear container.

**Specifications:**

**`value1`**

<code>start</code>, <code>end</code>, <code>center</code>

